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>
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;
*/
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.
*/
#define RUN_HOOKS_OPT_INIT { \
.env = STRVEC_INIT, \
.args = STRVEC_INIT, \
+ .stdout_to_stderr = 1, \
}
struct hook_cb_data {