public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hook: make stdout_to_stderr optional
@ 2026-01-13 11:56 Adrian Ratiu
  2026-01-13 13:36 ` Patrick Steinhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 30+ messages in thread
From: Adrian Ratiu @ 2026-01-13 11:56 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Patrick Steinhardt, Emily Shaffer, Adrian Ratiu,
	Chris Darroch, brian m. carlson

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.

We can introduce an extension for the breaking change of all hooks
sending stdout to stderr, however this just fixes the regression.

Reported-by: Chris Darroch <chrisd@apache.org>
Suggested-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
---
This is based on the latest master branch.
Pushed to GitHub: https://github.com/10ne1/git/tree/dev/aratiu/make-hook-stdout_to_stderr-optional-v1
Succesful CI run: https://github.com/10ne1/git/actions/runs/20954859587
---
 hook.c      | 2 +-
 hook.h      | 6 ++++++
 transport.c | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/hook.c b/hook.c
index 35211e5ed7..ebd9d9e26e 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 ae502178b9..2488db7133 100644
--- a/hook.h
+++ b/hook.h
@@ -39,6 +39,11 @@ struct run_hooks_opt
 	 */
 	unsigned int ungroup:1;
 
+	/**
+	 * Send the hook's stdout to stderr.
+	 */
+	unsigned int stdout_to_stderr:1;
+
 	/**
 	 * Path to file which should be piped to stdin for each hook.
 	 */
@@ -93,6 +98,7 @@ struct run_hooks_opt
 #define RUN_HOOKS_OPT_INIT { \
 	.env = STRVEC_INIT, \
 	.args = STRVEC_INIT, \
+	.stdout_to_stderr = 1, \
 }
 
 struct hook_cb_data {
diff --git a/transport.c b/transport.c
index 6d0f02be5d..8f0e5987ab 100644
--- a/transport.c
+++ b/transport.c
@@ -1372,6 +1372,7 @@ static int run_pre_push_hook(struct transport *transport,
 
 	opt.feed_pipe = pre_push_hook_feed_stdin;
 	opt.feed_pipe_cb_data = &data;
+	opt.stdout_to_stderr = 0;
 
 	ret = run_hooks_opt(the_repository, "pre-push", &opt);
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2026-01-18  8:45 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-13 11:56 [PATCH] hook: make stdout_to_stderr optional Adrian Ratiu
2026-01-13 13:36 ` Patrick Steinhardt
2026-01-13 13:55   ` Adrian Ratiu
2026-01-13 14:00 ` Junio C Hamano
2026-01-13 14:06   ` Junio C Hamano
2026-01-13 14:59     ` Adrian Ratiu
2026-01-13 15:22       ` Junio C Hamano
2026-01-13 15:37         ` Adrian Ratiu
2026-01-13 14:11   ` Adrian Ratiu
2026-01-13 23:45 ` [PATCH v2] hook: allow hooks to disable stdout_to_stderr Adrian Ratiu
2026-01-14  3:12   ` Jeff King
2026-01-14  8:46     ` Adrian Ratiu
2026-01-14  8:59       ` Adrian Ratiu
2026-01-14  9:36       ` Kristoffer Haugsbakk
2026-01-14 17:08       ` Jeff King
2026-01-14 17:19         ` Jeff King
2026-01-14 17:56           ` Adrian Ratiu
2026-01-14  6:13   ` Kristoffer Haugsbakk
2026-01-14 18:57 ` [PATCH v3 0/2] Fix two hook conversion regressions Adrian Ratiu
2026-01-14 18:57   ` [PATCH v3 1/2] hook: allow hooks to disable stdout_to_stderr Adrian Ratiu
2026-01-14 18:57   ` [PATCH v3 2/2] hook: make ungroup opt-out instead of opt-in Adrian Ratiu
2026-01-14 21:27     ` Jeff King
2026-01-14 22:45       ` Adrian Ratiu
2026-01-18  8:44     ` Kristoffer Haugsbakk
2026-01-15 14:15   ` [PATCH v3 0/2] Fix two hook conversion regressions Junio C Hamano
2026-01-15 17:19     ` Adrian Ratiu
2026-01-15 17:33       ` Junio C Hamano
2026-01-15 17:53         ` Adrian Ratiu
2026-01-15 20:27           ` Junio C Hamano
2026-01-15 21:24             ` Adrian Ratiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox