summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-02-18 13:53:27 -0800
committerJunio C Hamano <gitster@pobox.com>2022-02-18 13:53:27 -0800
commit991b4d47f0accd3955d05927d5ce434e03ffbdb6 (patch)
treeb60f5608c4a0f3a04014e57a9fbd024dadf35ef3 /refs.c
parentbcd020f88e1e22f38422ac3f73ab06b34ec4bef1 (diff)
parent2ed1b64ebdeefc7f9473ae159fb45ff0c6cf121a (diff)
downloadgit-991b4d47f0accd3955d05927d5ce434e03ffbdb6.tar.gz
Merge branch 'ps/avoid-unnecessary-hook-invocation-with-packed-refs'
Because a deletion of ref would need to remove it from both the loose ref store and the packed ref store, a delete-ref operation that logically removes one ref may end up invoking ref-transaction hook twice, which has been corrected. * ps/avoid-unnecessary-hook-invocation-with-packed-refs: refs: skip hooks when deleting uncovered packed refs refs: do not execute reference-transaction hook on packing refs refs: demonstrate excessive execution of the reference-transaction hook refs: allow skipping the reference-transaction hook refs: allow passing flags when beginning transactions refs: extract packed_refs_delete_refs() to allow control of transaction
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 7017ae5980..d680de3bc0 100644
--- a/refs.c
+++ b/refs.c
@@ -793,7 +793,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
struct ref_transaction *transaction;
struct strbuf err = STRBUF_INIT;
- transaction = ref_store_transaction_begin(refs, &err);
+ transaction = ref_store_transaction_begin(refs, 0, &err);
if (!transaction ||
ref_transaction_delete(transaction, refname, old_oid,
flags, msg, &err) ||
@@ -998,6 +998,7 @@ int read_ref_at(struct ref_store *refs, const char *refname,
}
struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
+ unsigned int flags,
struct strbuf *err)
{
struct ref_transaction *tr;
@@ -1005,12 +1006,13 @@ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs,
CALLOC_ARRAY(tr, 1);
tr->ref_store = refs;
+ tr->flags = flags;
return tr;
}
struct ref_transaction *ref_transaction_begin(struct strbuf *err)
{
- return ref_store_transaction_begin(get_main_ref_store(the_repository), err);
+ return ref_store_transaction_begin(get_main_ref_store(the_repository), 0, err);
}
void ref_transaction_free(struct ref_transaction *transaction)
@@ -1149,7 +1151,7 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
struct strbuf err = STRBUF_INIT;
int ret = 0;
- t = ref_store_transaction_begin(refs, &err);
+ t = ref_store_transaction_begin(refs, 0, &err);
if (!t ||
ref_transaction_update(t, refname, new_oid, old_oid, flags, msg,
&err) ||
@@ -2065,6 +2067,9 @@ static int run_transaction_hook(struct ref_transaction *transaction,
const char *hook;
int ret = 0, i;
+ if (transaction->flags & REF_TRANSACTION_SKIP_HOOK)
+ return 0;
+
hook = find_hook("reference-transaction");
if (!hook)
return ret;