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
Apr 24, 2015 at 13:35 UTC
cbf50f9e3d8e54f09ebbe6159a1bdd622c6c2f26
1 file changed
+9
-9
refs.c
+9
-9
@@ -3763,16 +3763,16 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3763
/* Acquire all locks while verifying old values */
3764
for (i = 0; i < n; i++) {
3765
struct ref_update *update = updates[i];
3766
- unsigned int flags = update->flags;
3766
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;
3770
update->lock = lock_ref_sha1_basic(
3771
update->refname,
3772
((update->flags & REF_HAVE_OLD) ?
3773
update->old_sha1 : NULL),
3774
NULL,
3775
- flags,
3775
+ update->flags,
3776
&update->type);
3777
if (!update->lock) {
3778
ret = (errno == ENOTDIR)
@@ -3787,9 +3787,9 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3787
/* Perform updates first so live commits remain referenced */
3788
for (i = 0; i < n; i++) {
3789
struct ref_update *update = updates[i];
3790
- int flags = update->flags;
3790
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)) {
3793
int overwriting_symref = ((update->type & REF_ISSYMREF) &&
3794
(update->flags & REF_NODEREF));
3795
@@ -3822,15 +3822,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
3822
/* Perform deletes now that updates are safely completed */
3823
for (i = 0; i < n; i++) {
3824
struct ref_update *update = updates[i];
3825
- int flags = update->flags;
3825
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)) {
3828
if (delete_ref_loose(update->lock, update->type, err)) {
3829
ret = TRANSACTION_GENERIC_ERROR;
3830
goto cleanup;
3831
}
3832
3833
- if (!(flags & REF_ISPRUNING))
3833
+ if (!(update->flags & REF_ISPRUNING))
3834
string_list_append(&refs_to_delete,
3835
update->lock->ref_name);
3836
}