hook API: add a run_hooks() wrapper

Add a run_hooks() wrapper, we'll use it in subsequent commits for the simple cases of wanting to run a single hook under a given name, without providing options such as "env" or "args". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Emily Shaffer <emilyshaffer@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Dec 22, 2021 at 04:59 UTC 474c119fda1c323652ccb35124d5c001f48e008a
2 files changed +13
hook.c
+7
@@ -142,3 +142,10 @@ cleanup:
142 run_hooks_opt_clear(options);
143 return ret;
144 }
145 +
146 +int run_hooks(const char *hook_name)
147 +{
148 + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
149 +
150 + return run_hooks_opt(hook_name, &opt);
151 +}
hook.h
+6
@@ -48,4 +48,10 @@ int hook_exists(const char *hookname);
48 * error().
49 */
50 int run_hooks_opt(const char *hook_name, struct run_hooks_opt *options);
51 +
52 +/**
53 + * A wrapper for run_hooks_opt() which provides a dummy "struct
54 + * run_hooks_opt" initialized with "RUN_HOOKS_OPT_INIT".
55 + */
56 +int run_hooks(const char *hook_name);
57 #endif