From 9fdaa6788924d4bb5ffc3a5908dae8a50e072f77 Mon Sep 17 00:00:00 2001 From: Emily Shaffer Date: Thu, 19 Feb 2026 00:23:47 +0200 Subject: hook: add "git hook list" command The previous commit introduced an ability to run multiple commands for hook events and next commit will introduce the ability to define hooks from configs, in addition to the "traditional" hooks from the hookdir. Introduce a new command "git hook list" to make inspecting hooks easier both for users and for the tests we will add. Further commits will expand on this, e.g. by adding a -z output mode. Signed-off-by: Emily Shaffer Signed-off-by: Adrian Ratiu Signed-off-by: Junio C Hamano --- hook.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'hook.c') diff --git a/hook.c b/hook.c index c008a7232d..979a97a538 100644 --- a/hook.c +++ b/hook.c @@ -61,7 +61,7 @@ static void hook_clear(struct hook *h, cb_data_free_fn cb_data_free) free(h); } -static void hook_list_clear(struct string_list *hooks, cb_data_free_fn cb_data_free) +void hook_list_clear(struct string_list *hooks, cb_data_free_fn cb_data_free) { struct string_list_item *item; @@ -101,20 +101,7 @@ static void list_hooks_add_default(struct repository *r, const char *hookname, string_list_append(hook_list, hook_path)->util = h; } -/* - * Provides a list of hook commands to run for the 'hookname' event. - * - * This function consolidates hooks from two sources: - * 1. The config-based hooks (not yet implemented). - * 2. The "traditional" hook found in the repository hooks directory - * (e.g., .git/hooks/pre-commit). - * - * The list is ordered by execution priority. - * - * The caller is responsible for freeing the memory of the returned list - * using string_list_clear() and free(). - */ -static struct string_list *list_hooks(struct repository *r, const char *hookname, +struct string_list *list_hooks(struct repository *r, const char *hookname, struct run_hooks_opt *options) { struct string_list *hook_head; -- cgit v1.3