[PATCH 07/10] hooks: allow callers to capture output
- From
Adrian Ratiu <adrian.ratiu@collabora.com>
- Date
- Sep 25, 2025, 12:53 UTC
- Message-ID
- <20250925125352.1728840-8-adrian.ratiu@collabora.com>
- In-Reply-To
- <20250925125352.1728840-1-adrian.ratiu@collabora.com>
From: Emily Shaffer <emilyshaffer@google.com>
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> --- hook.c | 1 + hook.h | 8 ++++++++ 2 files changed, 9 insertions(+)
diff --git a/hook.c b/hook.c index 199c210b97..e15ee08f60 100644 --- a/hook.c +++ b/hook.c @@ -145,6 +145,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_sideband = options->consume_sideband, .task_finished = notify_hook_finished, .data = &cb_data, diff --git a/hook.h b/hook.h index 8fdbc8c673..a862858c1b 100644 --- a/hook.h +++ b/hook.h @@ -56,6 +56,14 @@ struct run_hooks_opt * Only useful if you are 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_sideband_fn consume_sideband; }; #define RUN_HOOKS_OPT_INIT { \
-- 2.49.1