aboutsummaryrefslogtreecommitdiff
path: root/hook.h
diff options
context:
space:
mode:
authorAdrian Ratiu <adrian.ratiu@collabora.com>2026-01-28 23:39:21 +0200
committerJunio C Hamano <gitster@pobox.com>2026-01-28 15:47:03 -0800
commitd816637f6c253e3829c4c6e817c7749b3a4f8bf4 (patch)
tree9e2de39912bfb95d8460788b81c781b4ae711ad5 /hook.h
parente8ee80cfb692139d0ca305995effe253b7a00463 (diff)
downloadgit-d816637f6c253e3829c4c6e817c7749b3a4f8bf4.tar.xz
hook: allow separate std[out|err] streams
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 <chrisd@apache.org> Suggested-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'hook.h')
-rw-r--r--hook.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/hook.h b/hook.h
index 2169d4a6bd..2c8a23a569 100644
--- a/hook.h
+++ b/hook.h
@@ -35,6 +35,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.
*/
const char *path_to_stdin;
@@ -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 {