All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Tom G. Christensen" <tgc@jupiterrise.com>,
	Elia Pinto <gitter.spiros@gmail.com>,
	git@vger.kernel.org
Subject: Re: Hardcoded #!/bin/sh in t5532 causes problems on Solaris
Date: Sat, 09 Apr 2016 17:37:43 -0700	[thread overview]
Message-ID: <xmqqmvp2ti20.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160409223738.GA1738@sigill.intra.peff.net> (Jeff King's message of "Sat, 9 Apr 2016 18:37:39 -0400")

Jeff King <peff@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 &&

  reply	other threads:[~2016-04-10  0:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-09 20:27 Hardcoded #!/bin/sh in t5532 causes problems on Solaris Tom G. Christensen
2016-04-09 21:04 ` Jeff King
2016-04-09 22:29   ` Tom G. Christensen
2016-04-09 22:37     ` Jeff King
2016-04-10  0:37       ` Junio C Hamano [this message]
2016-04-10 19:01         ` Junio C Hamano
2016-04-10 21:51           ` Eric Sunshine
2016-04-11 16:42             ` Junio C Hamano
2016-04-11 17:27           ` Jeff King
2016-04-11 17:32         ` Jeff King
2016-04-12 16:58           ` Junio C Hamano
2016-04-12 17:12             ` Junio C Hamano
2016-04-12 17:23               ` Jeff King
2016-04-12 17:22             ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqmvp2ti20.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitter.spiros@gmail.com \
    --cc=peff@peff.net \
    --cc=tgc@jupiterrise.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.