]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3404: use write_script
authorJunio C Hamano <gitster@pobox.com>
Tue, 12 Apr 2016 16:59:59 +0000 (09:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Apr 2016 16:59:59 +0000 (09:59 -0700)
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>
t/t3404-rebase-interactive.sh

index 544f9ad50831e29095a9f143bf414e08fed46d9e..d6d65a3a9435a456f8efad15b8c7c63db00a8e5f 100755 (executable)
@@ -555,10 +555,9 @@ test_expect_success 'rebase a detached HEAD' '
 test_expect_success 'rebase a commit violating pre-commit' '
 
        mkdir -p .git/hooks &&
-       PRE_COMMIT=.git/hooks/pre-commit &&
-       echo "#!/bin/sh" > $PRE_COMMIT &&
-       echo "test -z \"\$(git diff --cached --check)\"" >> $PRE_COMMIT &&
-       chmod a+x $PRE_COMMIT &&
+       write_script .git/hooks/pre-commit <<-\EOF &&
+       test -z "$(git diff --cached --check)"
+       EOF
        echo "monde! " >> file1 &&
        test_tick &&
        test_must_fail git commit -m doesnt-verify file1 &&