Skip to content

Commit 805cf6e

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4da50de commit 805cf6e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

refs.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,16 +3802,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
38023802
/* Acquire all locks while verifying old values */
38033803
for (i = 0; i < n; i++) {
38043804
struct ref_update *update = updates[i];
3805-
int flags = update->flags;
38063805

38073806
if (is_null_sha1(update->new_sha1))
3808-
flags |= REF_DELETING;
3807+
update->flags |= REF_DELETING;
38093808
update->lock = lock_ref_sha1_basic(update->refname,
38103809
(update->have_old ?
38113810
update->old_sha1 :
38123811
NULL),
38133812
NULL,
3814-
flags,
3813+
update->flags,
38153814
&update->type);
38163815
if (!update->lock) {
38173816
ret = (errno == ENOTDIR)
@@ -3827,7 +3826,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
38273826
for (i = 0; i < n; i++) {
38283827
struct ref_update *update = updates[i];
38293828

3830-
if (!is_null_sha1(update->new_sha1)) {
3829+
if (!(update->flags & REF_DELETING)) {
38313830
if (!update->lock->force_write &&
38323831
!hashcmp(update->lock->old_sha1, update->new_sha1)) {
38333832
unlock_ref(update->lock);

0 commit comments

Comments
 (0)