Skip to content

Commit 958fbc7

Browse files
pks-tgitster
authored andcommitted
refs: allow skipping the reference-transaction hook
The reference-transaction hook is executing whenever we prepare, commit or abort a reference transaction. While this is mostly intentional, in case of the files backend we're leaking the implementation detail that the store is in fact a composite store with one loose and one packed backend to the caller. So while we want to execute the hook for all logical updates, executing it for such implementation details is unexpected. Prepare for a fix by adding a new flag which allows to skip execution of the hook. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fbe73f6 commit 958fbc7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

refs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,6 +2084,9 @@ static int run_transaction_hook(struct ref_transaction *transaction,
20842084
const char *hook;
20852085
int ret = 0, i;
20862086

2087+
if (transaction->flags & REF_TRANSACTION_SKIP_HOOK)
2088+
return 0;
2089+
20872090
hook = find_hook("reference-transaction");
20882091
if (!hook)
20892092
return ret;

refs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,11 @@ enum action_on_err {
568568
UPDATE_REFS_QUIET_ON_ERR
569569
};
570570

571+
/*
572+
* Skip executing the reference-transaction hook.
573+
*/
574+
#define REF_TRANSACTION_SKIP_HOOK (1 << 0)
575+
571576
/*
572577
* Begin a reference transaction. The reference transaction must
573578
* be freed by calling ref_transaction_free().

0 commit comments

Comments
 (0)