ref_transaction_commit(): remove the local flags variable
Instead, work directly with update->flags. This has the advantage that the REF_DELETING bit, set in the first loop, can be read in the second loop instead of having to be recomputed. Plus, it was potentially confusing having both update->flags and flags, which sometimes had different values. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 10, 2015 at 04:45 UTC
805cf6e938fa0fe421e85f2274e67194df559cb5
1 file changed
+3
-4
refs.c
+3
-4
@@ -3802,16 +3802,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3802
/* Acquire all locks while verifying old values */
3803
for (i = 0; i < n; i++) {
3804
struct ref_update *update = updates[i];
3805
- int flags = update->flags;
3805
3806
if (is_null_sha1(update->new_sha1))
3808
- flags |= REF_DELETING;
3807
+ update->flags |= REF_DELETING;
3808
update->lock = lock_ref_sha1_basic(update->refname,
3809
(update->have_old ?
3810
update->old_sha1 :
3811
NULL),
3812
NULL,
3814
- flags,
3813
+ update->flags,
3814
&update->type);
3815
if (!update->lock) {
3816
ret = (errno == ENOTDIR)
@@ -3827,7 +3826,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3826
for (i = 0; i < n; i++) {
3827
struct ref_update *update = updates[i];
3828
3830
- if (!is_null_sha1(update->new_sha1)) {
3829
+ if (!(update->flags & REF_DELETING)) {
3830
if (!update->lock->force_write &&
3831
!hashcmp(update->lock->old_sha1, update->new_sha1)) {
3832
unlock_ref(update->lock);