]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ref_transaction_commit(): remove the local flags variable
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 10 May 2015 02:45:36 +0000 (04:45 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 May 2015 04:25:27 +0000 (21:25 -0700)
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>
refs.c

diff --git a/refs.c b/refs.c
index 76609bff43f7c6eb5dc7b96d5987ef1b0d263990..58b118243cb0adb790cb386f5daa9b0cca8c21d2 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -3802,16 +3802,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
        /* Acquire all locks while verifying old values */
        for (i = 0; i < n; i++) {
                struct ref_update *update = updates[i];
-               int flags = update->flags;
 
                if (is_null_sha1(update->new_sha1))
-                       flags |= REF_DELETING;
+                       update->flags |= REF_DELETING;
                update->lock = lock_ref_sha1_basic(update->refname,
                                                   (update->have_old ?
                                                    update->old_sha1 :
                                                    NULL),
                                                   NULL,
-                                                  flags,
+                                                  update->flags,
                                                   &update->type);
                if (!update->lock) {
                        ret = (errno == ENOTDIR)
@@ -3827,7 +3826,7 @@ int ref_transaction_commit(struct ref_transaction *transaction,
        for (i = 0; i < n; i++) {
                struct ref_update *update = updates[i];
 
-               if (!is_null_sha1(update->new_sha1)) {
+               if (!(update->flags & REF_DELETING)) {
                        if (!update->lock->force_write &&
                            !hashcmp(update->lock->old_sha1, update->new_sha1)) {
                                unlock_ref(update->lock);