Subject: Re: [PATCH v8 06/12] hook: allow separate std[out|err] streams

From: Chris Darroch <[email-masked]>
Date: Sun, 1 Feb 2026 19:17:09 -0800

Adrian Ratiu wrote:

> The hook API assumes that all hooks merge stdout to stderr.
> 
> This assumption is proven wrong by pre-push: some of its users
> actually expect separate stdout and stderr streams and merging
> them will cause a regression.
> 
> Therefore this adds a mechanism to allow pre-push to separate
> the streams, which will be used in the next commit.
> 
> The mechanism is generic via struct run_hooks_opt just in case
> there are any more surprise exceptions like this.
> 
> Reported-by: Chris Darroch <[email-masked]>
> Suggested-by: brian m. carlson <[email-masked]>
> Signed-off-by: Adrian Ratiu <[email-masked]>
> ---
>  hook.c |  2 +-
>  hook.h | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/hook.c b/hook.c
> index 5ddd7678d1..fde1f88ce8 100644
> --- a/hook.c
> +++ b/hook.c
> @@ -81,7 +81,7 @@ static int pick_next_hook(struct child_process *cp,
>  		cp->in = -1;
>  	}
>  
> -	cp->stdout_to_stderr = 1;
> +	cp->stdout_to_stderr = hook_cb->options->stdout_to_stderr;
>  	cp->trace2_hook_name = hook_cb->hook_name;
>  	cp->dir = hook_cb->options->dir;
>  
> diff --git a/hook.h b/hook.h
> index 2169d4a6bd..2c8a23a569 100644
> --- a/hook.h
> +++ b/hook.h
> @@ -34,6 +34,15 @@ struct run_hooks_opt
>  	 */
>  	int *invoked_hook;
>  
> +	/**
> +	 * Send the hook's stdout to stderr.
> +	 *
> +	 * This is the default behavior for all hooks except pre-push,
> +	 * which has separate stdout and stderr streams for backwards
> +	 * compatibility reasons.
> +	 */
> +	unsigned int stdout_to_stderr:1;
> +
>  	/**
>  	 * Path to file which should be piped to stdin for each hook.
>  	 */
> @@ -80,6 +89,7 @@ struct run_hooks_opt
>  #define RUN_HOOKS_OPT_INIT { \
>  	.env = STRVEC_INIT, \
>  	.args = STRVEC_INIT, \
> +	.stdout_to_stderr = 1, \
>  }
>  
>  struct hook_cb_data {
> 

   Thank you for all your work on this series!  FWIW, I can confirm
that the Git LFS shell test suite continues to pass with your full v8
patch series applied.

Chris.

-- 
GPG Key ID: 088335A9
GPG Key Fingerprint: 86CD 3297 7493 75BC F820  6715 F54F E648 0883 35A9