Skip to content

Commit 7bec7f5

Browse files
committed
t3404: use write_script
The test uses hardcoded #!/bin/sh to create a pre-commit hook script. Because the generated script uses $(command substitution), which is not supported by /bin/sh on some platforms (e.g. Solaris), the resulting pre-commit always fails. Which is not noticeable as the test that uses the hook is about checking the behaviour of the command when the hook fails ;-), but nevertheless it is not testing what we wanted to test. Use write_script so that the resulting script is run under the same shell our scripted Porcelain commands are run, which must support the necessary $(construct). Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a3bb8ca commit 7bec7f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

t/t3404-rebase-interactive.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,9 @@ test_expect_success 'rebase a detached HEAD' '
555555
test_expect_success 'rebase a commit violating pre-commit' '
556556
557557
mkdir -p .git/hooks &&
558-
PRE_COMMIT=.git/hooks/pre-commit &&
559-
echo "#!/bin/sh" > $PRE_COMMIT &&
560-
echo "test -z \"\$(git diff --cached --check)\"" >> $PRE_COMMIT &&
561-
chmod a+x $PRE_COMMIT &&
558+
write_script .git/hooks/pre-commit <<-\EOF &&
559+
test -z "$(git diff --cached --check)"
560+
EOF
562561
echo "monde! " >> file1 &&
563562
test_tick &&
564563
test_must_fail git commit -m doesnt-verify file1 &&

0 commit comments

Comments
 (0)