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

Re: [PATCH] merge: make merge state available to prepare-commit-msg hook

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jan 8, 2014, 20:06 UTC
Message-ID
<vpqr48ip7bm.fsf@anie.imag.fr>
In-Reply-To
<DA9E6645-82DC-4714-845F-423726F96A40@yaauie.com>
Ryan Biesemeyer <ryan@yaauie.com> writes:
Show 8 quoted lines
> index 3573751..89cdfe8 100755
> --- a/t/t7505-prepare-commit-msg-hook.sh
> +++ b/t/t7505-prepare-commit-msg-hook.sh
> @@ -181,5 +181,27 @@ test_expect_success 'with failing hook (merge)' '
>  	test_must_fail git merge other
>  
>  '
> +git merge --abort # cleanup, since the merge failed.

Please, avoid having code outside a test_expect_* (see t/README, " - Put all code inside test_expect_success and other assertions.").

Show 15 quoted lines
> +test_expect_success 'should have MERGE_HEAD (merge)' '
> +
> +	git checkout -B other HEAD@{1} &&
> +	echo "more" >> file &&
> +	git add file &&
> +	rm -f "$HOOK" &&
> +	git commit -m other &&
> +	git checkout - &&
> +	write_script "$HOOK" <<-EOF
> +	if [ -s "$(git rev-parse --git-dir)/MERGE_HEAD" ]; then
> +		exit 0
> +	else
> +		exit 1
> +	fi
> +	EOF
I think you lack one && for the write_script line.

There's another instance in the same file (probably where you got it from), you should add this to your patch series:

>From c3d754a2a16d98b31d43a7e45973821ae8adc043 Mon Sep 17 00:00:00 2001
From: Matthieu Moy <Matthieu.Moy@imag.fr>
Date: Wed, 8 Jan 2014 21:03:27 +0100
Subject: [PATCH] t7505: add missing &&
---
 t/t7505-prepare-commit-msg-hook.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
index 3573751..1c95652 100755
--- a/t/t7505-prepare-commit-msg-hook.sh
+++ b/t/t7505-prepare-commit-msg-hook.sh
@@ -174,7 +174,7 @@ test_expect_success 'with failing hook (merge)' '
 	git add file &&
 	rm -f "$HOOK" &&
 	git commit -m other &&
-	write_script "$HOOK" <<-EOF
+	write_script "$HOOK" <<-EOF &&
 	exit 1
 	EOF
 	git checkout - &&
-- 
1.8.5.rc3.4.g8bd3721

(a quick "git grep write_script" seems to show a lot of other instances,
but no time to dig this now sorry)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Ryan BiesemeyerNext: Ryan Biesemeyer
Message 3 of 18 in “merge: make merge state available to prepare-commit-msg hook”
  1. merge: make merge state available to prepare-commit-msg hookRyan Biesemeyer, Jan 8, 2014
  2. Ryan BiesemeyerJan 8, 2014
  3. Matthieu MoyJan 8, 2014
  4. Ryan BiesemeyerJan 8, 2014
  5. Jonathan NiederJan 8, 2014
  6. Matthieu MoyJan 8, 2014
  7. Jonathan NiederJan 8, 2014
  8. Matthieu MoyJan 9, 2014
  9. Ryan BiesemeyerJan 8, 2014
  10. 0/4 merge: make merge state available to prepare-commit-msg hookRyan Biesemeyer, Jan 9, 2014
  11. 1/4 t7505: add missing &&Ryan Biesemeyer, Jan 9, 2014
  12. 2/4 t7505: ensure cleanup after hook blocks mergeRyan Biesemeyer, Jan 9, 2014
  13. Matthieu MoyJan 9, 2014
  14. Junio C HamanoJan 10, 2014
  15. 3/4 merge: make prepare_to_commit responsible for write_merge_stateRyan Biesemeyer, Jan 9, 2014
  16. Junio C HamanoJan 11, 2014
  17. Junio C HamanoJan 11, 2014
  18. 4/4 merge: drop unused arg from abort_commit method signatureRyan Biesemeyer, Jan 9, 2014

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.