summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hook.c1
-rwxr-xr-xt/t1800-hook.sh31
2 files changed, 32 insertions, 0 deletions
diff --git a/hook.c b/hook.c
index 1d51be3b77..7451205657 100644
--- a/hook.c
+++ b/hook.c
@@ -144,6 +144,7 @@ int run_hooks_opt(const char *hook_name, struct run_hooks_opt *options)
cb_data.hook_path = abs_path.buf;
}
+ run_processes_parallel_ungroup = 1;
run_processes_parallel_tr2(jobs,
pick_next_hook,
notify_start_failure,
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 26ed5e11bc..210f429887 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -4,6 +4,7 @@ test_description='git-hook command'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
test_expect_success 'git hook usage' '
test_expect_code 129 git hook &&
@@ -120,4 +121,34 @@ test_expect_success 'git -c core.hooksPath=<PATH> hook run' '
test_cmp expect actual
'
+test_hook_tty () {
+ cat >expect <<-\EOF
+ STDOUT TTY
+ STDERR TTY
+ EOF
+
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+
+ test_commit -C repo A &&
+ test_commit -C repo B &&
+ git -C repo reset --soft HEAD^ &&
+
+ test_hook -C repo pre-commit <<-EOF &&
+ test -t 1 && echo STDOUT TTY >>actual || echo STDOUT NO TTY >>actual &&
+ test -t 2 && echo STDERR TTY >>actual || echo STDERR NO TTY >>actual
+ EOF
+
+ test_terminal git -C repo "$@" &&
+ test_cmp expect repo/actual
+}
+
+test_expect_success TTY 'git hook run: stdout and stderr are connected to a TTY' '
+ test_hook_tty hook run pre-commit
+'
+
+test_expect_success TTY 'git commit: stdout and stderr are connected to a TTY' '
+ test_hook_tty commit -m"B.new"
+'
+
test_done