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

Re: [PATCH v2] sequencer: require trailing NL in footers

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 26, 2017, 09:09 UTC
Message-ID
<alpine.DEB.2.20.1704261101250.3480@virtualbox>
In-Reply-To
<xmqqinlrudij.fsf@gitster.mtv.corp.google.com>
Hi Junio,
On Tue, 25 Apr 2017, Junio C Hamano wrote:
Show 27 quoted lines
> Jonathan Nieder <jrnieder@gmail.com> writes:
> 
> > Jonathan Tan wrote:
> >
> > [...]
> >> --- a/t/t3511-cherry-pick-x.sh
> >> +++ b/t/t3511-cherry-pick-x.sh
> >> @@ -208,6 +208,20 @@ test_expect_success 'cherry-pick -x -s adds sob even when trailing sob exists fo
> >>  	test_cmp expect actual
> >>  '
> >>  
> >> +test_expect_success 'cherry-pick -x handles commits with no NL at end of message' '
> >> +	pristine_detach initial &&
> >> +	sha1=$(printf "title\n\nSigned-off-by: a" | git commit-tree -p initial mesg-with-footer^{tree}) &&
> >
> > nit: Should this use a more typical sign-off line with an email
> > address, to avoid a false-positive success in case git becomes more
> > strict about its signoffs in the future?
> >
> > Something like
> >
> > 	printf "title\n\nSigned-off-by: S. I. Gner <signer@example.com>" >msg &&
> > 	sha1=$(git commit-tree -p initial mesg-with-footer^{tree} <msg) &&
> > 	...
> 
> That is a good point and has an added benefit that the test script
> becomes easier to follow.

If you already try to make it easier to follow, you might just as well go the whole nine yards:

Show 21 quoted lines
> diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh
> index 6f518020b2..c2b143802d 100755
> --- a/t/t3511-cherry-pick-x.sh
> +++ b/t/t3511-cherry-pick-x.sh
> @@ -210,12 +210,14 @@ test_expect_success 'cherry-pick -x -s adds sob even when trailing sob exists fo
>  
>  test_expect_success 'cherry-pick -x handles commits with no NL at end of message' '
>  	pristine_detach initial &&
> -	sha1=$(printf "title\n\nSigned-off-by: a" | git commit-tree -p initial mesg-with-footer^{tree}) &&
> +	signer="S. I. Gner <signer@example.com>" &&
> +	printf "title\n\nSigned-off-by: %s" "$signer" >msg &&
> +	sha1=$(git commit-tree -p initial mesg-with-footer^{tree} <msg) &&
>  	git cherry-pick -x $sha1 &&
>  	cat <<-EOF >expect &&
>  		title
>  
> -		Signed-off-by: a
> +		Signed-off-by: $signer
>  		(cherry picked from commit $sha1)
>  	EOF
>  	git log -1 --pretty=format:%B >actual &&

It is even easier to read `--format=%B` than `--pretty=format:%B`, and as `%B` does *not* indent, the indentation in the lines writing the `expect` file is bogus anyway. And with the `msg` file having most of the stuff already, we Do Not Need To Repeat Ourselves:

	printf '\n(cherry picked from commit %s)\n' $sha1 >>msg &&
	git log -1 --format=%B >actual &&
	test_cmp msg actual

Ciao, Dscho

Previous: Junio C HamanoNext: Jonathan Tan
Message 17 of 18 in “[GIT 2.12.2 REGRESSION] git cherry-pick -x”
  1. Brian NorrisApr 21, 2017
  2. Stefan BellerApr 21, 2017
  3. Jeff KingApr 21, 2017
  4. sequencer: require trailing NL in footersJonathan Tan, Apr 25, 2017
  5. Stefan BellerApr 25, 2017
  6. Jonathan TanApr 25, 2017
  7. Stefan BellerApr 25, 2017
  8. Johannes SchindelinApr 25, 2017
  9. Jonathan NiederApr 25, 2017
  10. Brian NorrisApr 25, 2017
  11. Brian NorrisApr 26, 2017
  12. Johannes SchindelinApr 25, 2017
  13. Jonathan NiederApr 25, 2017
  14. sequencer: require trailing NL in footersJonathan Tan, Apr 25, 2017
  15. Jonathan NiederApr 26, 2017
  16. Junio C HamanoApr 26, 2017
  17. Johannes SchindelinApr 26, 2017
  18. sequencer: add newline before adding footersJonathan Tan, Apr 26, 2017

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.