Skip to content

Commit cbf50f9

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 61e51e0 commit cbf50f9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

refs.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3763,16 +3763,16 @@ int ref_transaction_commit(struct ref_transaction *transaction,
37633763
/* Acquire all locks while verifying old values */
37643764
for (i = 0; i < n; i++) {
37653765
struct ref_update *update = updates[i];
3766-
unsigned int flags = update->flags;
37673766

3768-
if ((flags & REF_HAVE_NEW) && is_null_sha1(update->new_sha1))
3769-
flags |= REF_DELETING;
3767+
if ((update->flags & REF_HAVE_NEW) &&
3768+
is_null_sha1(update->new_sha1))
3769+
update->flags |= REF_DELETING;
37703770
update->lock = lock_ref_sha1_basic(
37713771
update->refname,
37723772
((update->flags & REF_HAVE_OLD) ?
37733773
update->old_sha1 : NULL),
37743774
NULL,
3775-
flags,
3775+
update->flags,
37763776
&update->type);
37773777
if (!update->lock) {
37783778
ret = (errno == ENOTDIR)
@@ -3787,9 +3787,9 @@ int ref_transaction_commit(struct ref_transaction *transaction,
37873787
/* Perform updates first so live commits remain referenced */
37883788
for (i = 0; i < n; i++) {
37893789
struct ref_update *update = updates[i];
3790-
int flags = update->flags;
37913790

3792-
if ((flags & REF_HAVE_NEW) && !is_null_sha1(update->new_sha1)) {
3791+
if ((update->flags & REF_HAVE_NEW)
3792+
&& !is_null_sha1(update->new_sha1)) {
37933793
int overwriting_symref = ((update->type & REF_ISSYMREF) &&
37943794
(update->flags & REF_NODEREF));
37953795

@@ -3822,15 +3822,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
38223822
/* Perform deletes now that updates are safely completed */
38233823
for (i = 0; i < n; i++) {
38243824
struct ref_update *update = updates[i];
3825-
int flags = update->flags;
38263825

3827-
if ((flags & REF_HAVE_NEW) && is_null_sha1(update->new_sha1)) {
3826+
if ((update->flags & REF_HAVE_NEW)
3827+
&& is_null_sha1(update->new_sha1)) {
38283828
if (delete_ref_loose(update->lock, update->type, err)) {
38293829
ret = TRANSACTION_GENERIC_ERROR;
38303830
goto cleanup;
38313831
}
38323832

3833-
if (!(flags & REF_ISPRUNING))
3833+
if (!(update->flags & REF_ISPRUNING))
38343834
string_list_append(&refs_to_delete,
38353835
update->lock->ref_name);
38363836
}

0 commit comments

Comments
 (0)