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
This commit is contained in:
11
refs.c
11
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;
|
||||
|
Reference in New Issue
Block a user