[PATCH 23/27] hooks: allow callers to capture output
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 17, 2021, 10:22 UTC
- Message-ID
- <patch-23.27-7f7fcc0688-20210617T101217Z-avarab@gmail.com>
- In-Reply-To
- <cover-00.27-0000000000-20210617T101216Z-avarab@gmail.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 | 2 +- hook.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/hook.c b/hook.c index 2dca969f9e..e7f3b468ea 100644 --- a/hook.c +++ b/hook.c @@ -192,7 +192,7 @@ int run_found_hooks(const char *hook_name, const char *hook_path, pick_next_hook, notify_start_failure, options->feed_pipe, - NULL, + options->consume_sideband, notify_hook_finished, &cb_data, "hook", diff --git a/hook.h b/hook.h index b78a8e4805..1302efa590 100644 --- a/hook.h +++ b/hook.h @@ -66,6 +66,14 @@ struct run_hooks_opt */ feed_pipe_fn feed_pipe; void *feed_pipe_ctx; + + /* + * 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.32.0.576.g59759b6ca7d