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
Ryan Biesemeyer <ryan@yaauie.com>
Date
Jan 8, 2014, 20:21 UTC
Message-ID
<B19C65C1-C2D9-486F-AEA7-1497A3B5C5B4@yaauie.com>
In-Reply-To
<vpqr48ip7bm.fsf@anie.imag.fr>
On 2014-01-08, at 20:06Z, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
Show 13 quoted lines
> Ryan Biesemeyer <ryan@yaauie.com> writes:
> 
>> 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.").

In this case it was not immediately clear to me how to add cleanup to an existing test that dirtied the state of the test repository by leaving behind an in-progress merge. I see `test_cleanup` defined in the test lib & related functions, but see no examples of its use in the test suites. Could you advise?

Show 18 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.
Good catch.
> There's another instance in the same file (probably where you got it
> from), you should add this to your patch series:

I'm new to the mailing-list patch submission process; how would I go about adding it? Submit the cover-letter & patches again? Squash your commit into the relevant one of mine?

Show 31 quoted lines
> 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/
Thanks for the review.

-- Ryan Biesemeyer (@yaauie)

Previous: Matthieu MoyNext: Jonathan Nieder
Message 4 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.