prepare_push_cert_sha1(&opt);
/* set up sideband printer */
- if (use_sideband)
+ if (use_sideband) {
opt.consume_output = hook_output_to_sideband;
+ opt.ungroup = 0; /* mandatory for sideband output */
+ }
/* set up stdin callback */
feed_state.cmd = commands;
oid_to_hex(&cmd->new_oid),
NULL);
- if (use_sideband)
+ if (use_sideband) {
opt.consume_output = hook_output_to_sideband;
+ opt.ungroup = 0; /* mandatory for sideband output */
+ }
return run_hooks_opt(the_repository, "update", &opt);
}
if (!opt.args.nr)
return;
- if (use_sideband)
+ if (use_sideband) {
opt.consume_output = hook_output_to_sideband;
+ opt.ungroup = 0; /* mandatory for sideband output */
+ }
run_hooks_opt(the_repository, "post-update", &opt);
}
strvec_push(&opt.args, arg);
va_end(args);
- /* All commit hook use-cases require ungrouping child output. */
- opt.ungroup = 1;
-
opt.invoked_hook = invoked_hook;
return run_hooks_opt(the_repository, name, &opt);
}
check_stdout_merged_to_stderr push-to-checkout
'
+test_expect_success 'receive-pack hooks sideband output works' '
+ git init --bare target-sideband.git &&
+ test_commit sideband-a &&
+ git remote add origin-sideband ./target-sideband.git &&
+
+ # pre-receive hook
+ test_hook -C target-sideband.git pre-receive <<-\EOF &&
+ echo "stdout pre-receive"
+ echo "stderr pre-receive" >&2
+ EOF
+
+ git push origin-sideband HEAD:refs/heads/pre-receive 2>actual &&
+ test_grep "remote: stdout pre-receive" actual &&
+ test_grep "remote: stderr pre-receive" actual &&
+
+ # update hook
+ test_hook -C target-sideband.git update <<-\EOF &&
+ echo "stdout update"
+ echo "stderr update" >&2
+ EOF
+
+ test_commit sideband-b &&
+ git push origin-sideband HEAD:refs/heads/update 2>actual &&
+ test_grep "remote: stdout update" actual &&
+ test_grep "remote: stderr update" actual &&
+
+ # post-receive hook
+ test_hook -C target-sideband.git post-receive <<-\EOF &&
+ echo >&1 "stdout post-receive"
+ echo >&2 "stderr post-receive"
+ EOF
+
+ test_commit sideband-c &&
+ git push origin-sideband HEAD:refs/heads/post-receive 2>actual &&
+ test_grep "remote: stdout post-receive" actual &&
+ test_grep "remote: stderr post-receive" actual &&
+
+ # post-update hook
+ test_hook -C target-sideband.git post-update <<-\EOF &&
+ echo >&1 "stdout post-update"
+ echo >&2 "stderr post-update"
+ EOF
+
+ test_commit sideband-d &&
+ git push origin-sideband HEAD:refs/heads/post-update 2>actual &&
+ test_grep "remote: stdout post-update" actual &&
+ test_grep "remote: stderr post-update" actual
+'
+
test_done