branch.c: use ref transaction for all ref updates
commit620c04c50c463d639f08b1d1490dcdf3aeaf150e
authorRonnie Sahlberg <sahlberg@google.com>
Wed, 16 Apr 2014 23:21:53 +0000 (16 16:21 -0700)
committerJonathan Nieder <jrnieder@gmail.com>
Tue, 2 Sep 2014 20:43:11 +0000 (2 13:43 -0700)
tree50444f39e8722dce38c4b8961e4aac9c3de2933e
parente99d2616cd528d21f58f639df10895df781edba3
branch.c: use ref transaction for all ref updates

Change create_branch to use a ref transaction when creating the new branch.

This also fixes a race condition in the old code where two concurrent
create_branch could race since the lock_any_ref_for_update/write_ref_sha1
did not protect against the ref already existing. I.e. one thread could end up
overwriting a branch even if the forcing flag is false.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
branch.c