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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Apr 12, 2016 at 09:59 UTC
7bec7f50ae10ce760160ed4d11e47cd0494cb8d7
1 file changed
+3
-4
t/t3404-rebase-interactive.sh
+3
-4
@@ -555,10 +555,9 @@ test_expect_success 'rebase a detached HEAD' '
555
test_expect_success 'rebase a commit violating pre-commit' '
556
557
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
561
echo "monde! " >> file1 &&
562
test_tick &&
563
test_must_fail git commit -m doesnt-verify file1 &&