From 474c119fda1c323652ccb35124d5c001f48e008a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Wed, 22 Dec 2021 04:59:28 +0100 Subject: [PATCH] hook API: add a run_hooks() wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Emily Shaffer Signed-off-by: Junio C Hamano --- hook.c | 7 +++++++ hook.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/hook.c b/hook.c index a0917cf877..d67a114e62 100644 --- a/hook.c +++ b/hook.c @@ -142,3 +142,10 @@ cleanup: run_hooks_opt_clear(options); return ret; } + +int run_hooks(const char *hook_name) +{ + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT; + + return run_hooks_opt(hook_name, &opt); +} diff --git a/hook.h b/hook.h index 782385cc23..9c35878995 100644 --- a/hook.h +++ b/hook.h @@ -48,4 +48,10 @@ int hook_exists(const char *hookname); * error(). */ int run_hooks_opt(const char *hook_name, struct run_hooks_opt *options); + +/** + * A wrapper for run_hooks_opt() which provides a dummy "struct + * run_hooks_opt" initialized with "RUN_HOOKS_OPT_INIT". + */ +int run_hooks(const char *hook_name); #endif