[PATCH v5 32/36] hooks: allow callers to capture output
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Sep 2, 2021, 13:11 UTC
- Message-ID
- <patch-v5-32.36-7d185cdf9d1-20210902T125111Z-avarab@gmail.com>
- In-Reply-To
- <cover-v5-00.36-00000000000-20210902T125110Z-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 | 3 ++- hook.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/hook.c b/hook.c index 169287ad152..7f93fe40dba 100644 --- a/hook.c +++ b/hook.c @@ -174,12 +174,13 @@ int run_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", hook_name); + if (options->absolute_path) strbuf_release(&abs_path); free(my_hook.feed_pipe_cb_data); diff --git a/hook.h b/hook.h index 4e26b8d658d..a85e3e6981b 100644 --- a/hook.h +++ b/hook.h @@ -47,6 +47,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.33.0.816.g1ba32acadee