From fbe73f61cbc29f6c4a85478cf792c37dbe5aa26c Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 17 Jan 2022 09:12:35 +0100 Subject: refs: allow passing flags when beginning transactions We do not currently have any flags when creating reference transactions, but we'll add one to disable execution of the reference transaction hook in some cases. Allow passing flags to `ref_store_transaction_begin()` to prepare for this change. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- refs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'refs.h') diff --git a/refs.h b/refs.h index 92360e55a2..31f7bf9642 100644 --- a/refs.h +++ b/refs.h @@ -231,7 +231,7 @@ char *repo_default_branch_name(struct repository *r, int quiet); * struct strbuf err = STRBUF_INIT; * int ret = 0; * - * transaction = ref_store_transaction_begin(refs, &err); + * transaction = ref_store_transaction_begin(refs, 0, &err); * if (!transaction || * ref_transaction_update(...) || * ref_transaction_create(...) || @@ -573,6 +573,7 @@ enum action_on_err { * be freed by calling ref_transaction_free(). */ struct ref_transaction *ref_store_transaction_begin(struct ref_store *refs, + unsigned int flags, struct strbuf *err); struct ref_transaction *ref_transaction_begin(struct strbuf *err); -- cgit v1.2.3 From 958fbc74e3d0fcc88b2065190e23db556a963644 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Mon, 17 Jan 2022 09:12:39 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- refs.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'refs.h') diff --git a/refs.h b/refs.h index 31f7bf9642..d4056f9fe2 100644 --- a/refs.h +++ b/refs.h @@ -568,6 +568,11 @@ enum action_on_err { UPDATE_REFS_QUIET_ON_ERR }; +/* + * Skip executing the reference-transaction hook. + */ +#define REF_TRANSACTION_SKIP_HOOK (1 << 0) + /* * Begin a reference transaction. The reference transaction must * be freed by calling ref_transaction_free(). -- cgit v1.2.3