]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hooks: allow callers to capture output
authorEmily Shaffer <emilyshaffer@google.com>
Thu, 18 Dec 2025 17:11:23 +0000 (19:11 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Dec 2025 04:46:27 +0000 (13:46 +0900)
Some server-side hooks will require capturing output to send over
sideband instead of printing directly to stderr. Expose that capability.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hook.c
hook.h

diff --git a/hook.c b/hook.c
index 00a1e2ad22a9d77daa4c221bd5d21105e85c2ed7..35211e5ed7c474966a3d0e15ff8d74a12fd4c409 100644 (file)
--- a/hook.c
+++ b/hook.c
@@ -158,6 +158,7 @@ int run_hooks_opt(struct repository *r, const char *hook_name,
                .get_next_task = pick_next_hook,
                .start_failure = notify_start_failure,
                .feed_pipe = options->feed_pipe,
+               .consume_output = options->consume_output,
                .task_finished = notify_hook_finished,
 
                .data = &cb_data,
diff --git a/hook.h b/hook.h
index 78a1a44690ef34a682d9555f8ab7ccaed50e87aa..ae502178b9bfad6dcaed21cfb6bb7457dfe5bd07 100644 (file)
--- a/hook.h
+++ b/hook.h
@@ -80,6 +80,14 @@ struct run_hooks_opt
         * Only useful when using `run_hooks_opt.feed_pipe`, otherwise ignore it.
         */
        void *feed_pipe_cb_data;
+
+       /*
+        * Populate this to capture output and prevent it from being printed to
+        * stderr. This will be passed directly through to
+        * run_command:run_parallel_processes(). See t/helper/test-run-command.c
+        * for an example.
+        */
+       consume_output_fn consume_output;
 };
 
 #define RUN_HOOKS_OPT_INIT { \