hooks: allow callers to capture output
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>
Emily Shaffer committed
Dec 26, 2025 at 14:23 UTC
53254bfa1b4e91bab2c675d1a6b561026f7b573a
2 files changed
+9
hook.c
+1
@@ -158,6 +158,7 @@ int run_hooks_opt(struct repository *r, const char *hook_name,
158
.get_next_task = pick_next_hook,
159
.start_failure = notify_start_failure,
160
.feed_pipe = options->feed_pipe,
161
+ .consume_output = options->consume_output,
162
.task_finished = notify_hook_finished,
163
164
.data = &cb_data,
hook.h
+8
@@ -80,6 +80,14 @@ struct run_hooks_opt
80
* Only useful when using `run_hooks_opt.feed_pipe`, otherwise ignore it.
81
*/
82
void *feed_pipe_cb_data;
83
+
84
+ /*
85
+ * Populate this to capture output and prevent it from being printed to
86
+ * stderr. This will be passed directly through to
87
+ * run_command:run_parallel_processes(). See t/helper/test-run-command.c
88
+ * for an example.
89
+ */
90
+ consume_output_fn consume_output;
91
};
92
93
#define RUN_HOOKS_OPT_INIT { \