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

Re: [PATCH 1/4] t/t7502: compare entire commit message with what was expected

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 19, 2013, 17:24 UTC
Message-ID
<7vhal86wt4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130219050813.GC19757@elie.Belkin>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 5 quoted lines
> The downside (not a new problem, but a downside nonetheless) is that
> it means the test doesn't demonstrate what --cleanup=verbatim --status
> will do.
>
> How about something like this?

Can't we be a bit more robust by not using a hardcoded block of lines as the "expect" string? You could for example use what you would see in your editor when "git commit" is run without the "-t" option to form the expected pattern, no?

In any case, I think (1) a test for 'verbatim with status' is worth doing, and (2) it would be cleaner to do this as a separate step, perhaps on top of Brandon's 4-patch series.

Show 48 quoted lines
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
>
> diff --git i/t/t7502-commit.sh w/t/t7502-commit.sh
> index cbd7a459..64162fce 100755
> --- i/t/t7502-commit.sh
> +++ w/t/t7502-commit.sh
> @@ -180,15 +180,37 @@ test_expect_success 'verbose respects diff config' '
>  test_expect_success 'cleanup commit messages (verbatim option,-t)' '
>  
>  	echo >>negative &&
> -	{ echo;echo "# text";echo; } >expect &&
> -	git commit --cleanup=verbatim -t expect -a &&
> -	git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
> +	{
> +		echo &&
> +		echo "# text" &&
> +		echo
> +	} >template &&
> +	{
> +		cat template &&
> +		cat <<-\EOF &&
> +
> +		# Please enter the commit message for your changes. Lines starting
> +		# with '\''#'\'' will be kept; you may remove them yourself if you want to.
> +		# An empty message aborts the commit.
> +		#
> +		# Author:    A U Thor <author@example.com>
> +		#
> +		EOF
> +		git commit -a --dry-run
> +	} >expect &&
> +	git commit --cleanup=verbatim -t template -a &&
> +	git cat-file -p HEAD |sed -e "1,/^\$/d" >actual &&
>  	test_cmp expect actual
>  
>  '
>  
>  test_expect_success 'cleanup commit messages (verbatim option,-F)' '
>  
> +	{
> +		echo &&
> +		echo "# text" &&
> +		echo
> +	} >expect &&
>  	echo >>negative &&
>  	git commit --cleanup=verbatim -F expect -a &&
>  	git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
Previous: Jonathan Nieder
Message 19 of 19 in “t/t7502: compare entire commit message with what was expected”
  1. 1/4 t/t7502: compare entire commit message with what was expectedBrandon Casey, Feb 19, 2013
  2. 2/4 t7502: demonstrate breakage with a commit message with trailing newlinesBrandon Casey, Feb 19, 2013
  3. Jonathan NiederFeb 19, 2013
  4. 3/4 git-commit: only append a newline to -m mesg if necessaryBrandon Casey, Feb 19, 2013
  5. Jonathan NiederFeb 19, 2013
  6. 4/4 Documentation/git-commit.txt: correct a few minor grammatical mistakesBrandon Casey, Feb 19, 2013
  7. Jonathan NiederFeb 19, 2013
  8. Brandon CaseyFeb 19, 2013
  9. Jonathan NiederFeb 19, 2013
  10. Junio C HamanoFeb 19, 2013
  11. 4/4 Documentation/git-commit.txt: rework the --cleanup sectionBrandon Casey, Feb 19, 2013
  12. 4/4 Documentation/git-commit.txt: rework the --cleanup sectionBrandon Casey, Feb 19, 2013
  13. 4/4 Documentation/git-commit.txt: rework the --cleanup sectionBrandon Casey, Feb 19, 2013
  14. fixup! Documentation/git-commit.txt: rework the --cleanup sectionJonathan Nieder, Feb 19, 2013
  15. Brandon CaseyFeb 19, 2013
  16. Junio C HamanoFeb 19, 2013
  17. Jonathan NiederFeb 19, 2013
  18. Jonathan NiederFeb 19, 2013
  19. Junio C HamanoFeb 19, 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.