[PATCH 02/27] gc: use hook library for pre-auto-gc hook
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 17, 2021, 10:22 UTC
- Message-ID
- <patch-02.27-7209f73f28-20210617T101217Z-avarab@gmail.com>
- In-Reply-To
- <cover-00.27-0000000000-20210617T101216Z-avarab@gmail.com>
From: Emily Shaffer <emilyshaffer@google.com>
Using the hook.h library instead of the run-command.h library to run pre-auto-gc means that those hooks can be set up in config files, as well as in the hookdir. pre-auto-gc is called only from builtin/gc.c.
Signed-off-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- builtin/gc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/builtin/gc.c b/builtin/gc.c index f05d2f0a1a..a12641a691 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -32,6 +32,7 @@ #include "remote.h" #include "object-store.h" #include "exec-cmd.h" +#include "hook.h" #define FAILED_RUN "failed to run %s" @@ -348,6 +349,8 @@ static void add_repack_incremental_option(void) static int need_to_gc(void) { + struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT; + /* * Setting gc.auto to 0 or negative can disable the * automatic gc. @@ -394,8 +397,11 @@ static int need_to_gc(void) else return 0; - if (run_hook_le(NULL, "pre-auto-gc", NULL)) + if (run_hooks("pre-auto-gc", &hook_opt)) { + run_hooks_opt_clear(&hook_opt); return 0; + } + run_hooks_opt_clear(&hook_opt); return 1; }
-- 2.32.0.576.g59759b6ca7d