refs.c: make rename_ref use a transaction

Change rename_ref to use a single transaction to perform the ref rename.
Add a special flag for _delete so that we know this is a rename so we can
do magic delete and unlinks for the old ref before we start writing out the
new ref.
We have to do these deletes and creates in a careful order in order to
handle n -> n/n and n/n -> n renames since n will change between being a
directory and a file and this restricts when we can allow n/n.lock to exist.

Update test t5505. Since we now try to remove the parent directory for the old
ref during transaction commit for the rename (so that rename n/n -> n still
works) we do not need to rmdir it from the test.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
fetch.c: change s_update_ref to use a ref transaction

Change s_update_ref to use a ref transaction for the ref update.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
refs.c: make write_ref_sha1 static

No external users call write_ref_sha1 any more so lets declare it static.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>