Subject: Re: [PATCH v2] hook: allow hooks to disable stdout_to_stderr

From: "Kristoffer Haugsbakk" <[email-masked]>
Date: Wed, 14 Jan 2026 07:13:43 +0100

On Wed, Jan 14, 2026, at 00:45, Adrian Ratiu wrote:
> The last batch of hooks converted to the hook.[ch] API introduced
> a regression because pick_next_hook() always sets stdout_to_stderr
> for its child processes.
>
> Pre-push is the only hook API user which requires stdout_to_stderr
> to be 0, so it can be argued that pre-push needs fixing, however
> this will likely break many pre-push hooks, so it's better to allow
> it to be 0, i.e. to match the previous behavior.
>
> To prevent such regressions in the future, extend the hook tests to
> verify hooks write to the expected stdout vs stderr streams and
> maintain backward compatibility with the hooks output assumptions.
>
> The tests are independent of the actual hook implementations: I've
> tested they work the same before and after the hook.[ch] conversion
> and will continue to work after we eventually introduce parallel
> hook execution and config-based hooks.
>
> Reported-by: Chris Darroch <[email-masked]>
> Suggested-by: brian m. carlson <[email-masked]>
> Signed-off-by: Adrian Ratiu <[email-masked]>
> ---
> This is based on the latest master branch.
>
> Changes in v2:
> * Extended hook test coverage to detect future regressions (Junio, Patrick)
> * Reworded commit message and added explanatory comment (Junio, Patrick)
> * Set ungroup = 1 because grouping overrides stdout_to_stderr (Adrian)
>[snip]

This fixes the issue reported here: https://lore.kernel.org/git/[email-masked]/

(Subject: [BUG] push: pre-push hook that waits for stdin is slow)

Via: https://lore.kernel.org/git/[email-masked]/