Jeff King <p...@peff.net> writes:

> Hmm. t3404.40 does this:
>
>         echo "#!/bin/sh" > $PRE_COMMIT &&
>       echo "test -z \"\$(git diff --cached --check)\"" >>$PRE_COMMIT &&
>       chmod a+x $PRE_COMMIT &&
>
> So I'm pretty sure that $PRE_COMMIT script should be barfing each time
> it is called on Solaris. I think the test itself doesn't notice because
> "/bin/sh barfed" and "the pre-commit check said no" look the same from
> git's perspective (both non-zero exits), and we test only cases where we
> expect the hook to fail.

I looked at

    $ git grep -c '#! */bin/sh' t | grep -v ':1$'

and did a few just for fun.  Doing it fully may be a good
microproject for next year ;-)

 t/t1020-subdirectory.sh       |  6 +++---
 t/t2050-git-dir-relative.sh   | 11 ++++++-----
 t/t3404-rebase-interactive.sh |  7 +++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index 8e22b03..6dedb1c 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -142,9 +142,9 @@ test_expect_success 'GIT_PREFIX for built-ins' '
        # Use GIT_EXTERNAL_DIFF to test that the "diff" built-in
        # receives the GIT_PREFIX variable.
        printf "dir/" >expect &&
-       printf "#!/bin/sh\n" >diff &&
-       printf "printf \"\$GIT_PREFIX\"" >>diff &&
-       chmod +x diff &&
+       write_script diff <<-\EOF &&
+       printf "%s" "$GIT_PREFIX"
+       EOF
        (
                cd dir &&
                printf "change" >two &&
diff --git a/t/t2050-git-dir-relative.sh b/t/t2050-git-dir-relative.sh
index 21f4659..7a05b20 100755
--- a/t/t2050-git-dir-relative.sh
+++ b/t/t2050-git-dir-relative.sh
@@ -18,11 +18,12 @@ COMMIT_FILE="$(pwd)/output"
 export COMMIT_FILE
 
 test_expect_success 'Setting up post-commit hook' '
-mkdir -p .git/hooks &&
-echo >.git/hooks/post-commit "#!/bin/sh
-touch \"\${COMMIT_FILE}\"
-echo Post commit hook was called." &&
-chmod +x .git/hooks/post-commit'
+       mkdir -p .git/hooks &&
+       write_script .git/hooks/post-commit <<-\EOF
+       >"${COMMIT_FILE}"
+       echo Post commit hook was called.
+       EOF
+'
 
 test_expect_success 'post-commit hook used ordinarily' '
 echo initial >top &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index b79f442..d96d0e4 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -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 &&
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to