git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] merge: Honor prepare-commit-msg return code

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 2, 2013, 20:40 UTC
Message-ID
<7v623f2uam.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1357152170-5511-1-git-send-email-apelisse@gmail.com>
Antoine Pelisse <apelisse@gmail.com> writes:
> prepare-commit-msg hook is run when committing to prepare the log
> message. If the exit-status is non-zero, the commit should be aborted.

I was scratching my head why you CC'ed Jay, until I dug up 65969d4 (merge: honor prepare-commit-msg hook, 2011-02-14).

Show 6 quoted lines
> +test_expect_success 'with failing hook (merge)' '
> +
> +	git checkout -B other HEAD@{1} &&
> +	echo "more" >> file &&
> +	git add file &&
> +	chmod -x $HOOK &&

I have a feeling that this will break folks without POSIXPERM prerequisite.

How about doing it this way instead? This old test script seems to want a lot of style clean-ups, but I refrained from doing any in this fixlet.

Thanks.
 t/t7505-prepare-commit-msg-hook.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
index bc497bc..3573751 100755
--- a/t/t7505-prepare-commit-msg-hook.sh
+++ b/t/t7505-prepare-commit-msg-hook.sh
@@ -172,11 +172,12 @@ test_expect_success 'with failing hook (merge)' '
 	git checkout -B other HEAD@{1} &&
 	echo "more" >> file &&
 	git add file &&
-	chmod -x $HOOK &&
+	rm -f "$HOOK" &&
 	git commit -m other &&
-	chmod +x $HOOK &&
+	write_script "$HOOK" <<-EOF
+	exit 1
+	EOF
 	git checkout - &&
-	head=`git rev-parse HEAD` &&
 	test_must_fail git merge other
 
 '
Previous: Antoine PelisseNext: Antoine Pelisse
Message 3 of 6 in “merge: Honor prepare-commit-msg return code”
  1. merge: Honor prepare-commit-msg return codeAntoine Pelisse, Jan 2, 2013
  2. Antoine PelisseJan 2, 2013
  3. Junio C HamanoJan 2, 2013
  4. Antoine PelisseJan 2, 2013
  5. Junio C HamanoJan 2, 2013
  6. Antoine PelisseJan 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.