[PATCH 13/31] refs.c: update the list of deleted refs during _update instead of _commit
- From
Ronnie Sahlberg <sahlberg@google.com>
- Date
- May 14, 2014, 22:13 UTC
- Message-ID
- <1400105610-21194-14-git-send-email-sahlberg@google.com>
- In-Reply-To
- <1400105610-21194-1-git-send-email-sahlberg@google.com>
When deleting refs during a transaction, update the list of the refs to be deleted already during _update instead of waiting until the _commit stage.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> --- refs.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/refs.c b/refs.c index cc31efe..3249576 100644 --- a/refs.c +++ b/refs.c @@ -3431,6 +3431,13 @@ int transaction_update_sha1(struct ref_transaction *transaction, hashcpy(update->old_sha1, old_sha1); if (msg) update->msg = xstrdup(msg); + + /* This is a deletion of a ref that exists as a packed ref which means + * we do not need to check against this ref for name collissions + * during locking. + */ + if (update->flags & REF_ISPACKONLY) + add_delname(transaction, update->refname); return 0; } @@ -3550,15 +3557,6 @@ int transaction_commit(struct ref_transaction *transaction, if (ret) goto cleanup; - for (i = 0; i < n; i++) { - struct ref_update *update = updates[i]; - - if (update->update_type != UPDATE_SHA1) - continue; - if (update->flags & REF_ISPACKONLY) - add_delname(transaction, update->refname); - } - /* Acquire all ref locks while verifying old values */ for (i = 0; i < n; i++) { struct ref_update *update = updates[i];
-- 2.0.0.rc3.506.g3739a35