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

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

From
Brandon Casey <drafnel@gmail.com>
Date
Feb 19, 2013, 04:17 UTC
Message-ID
<1361247427-438-1-git-send-email-drafnel@gmail.com>

This test attempts to verify that a commit in "verbatim" mode, when supplied a commit template, produces a commit in which the commit message matches exactly the template that was supplied. But, since the commit operation appends additional instructions for the user as comments in the commit buffer, which would cause the comparison to fail, this test decided to compare only the first three lines (the length of the template) of the resulting commit message to the original template file.

This has two problems.
  1. It does not allow the template to be lengthened or shortened
     without also modifying the number of lines that are considered
     significant (i.e. the argument to 'head -n').
  2. It will not catch a bug in git that causes git to append additional
     lines to the commit message.

So, let's use the --no-status option to 'git commit' which will cause git to refrain from appending the lines of instructional text to the commit message. This will allow the entire resulting commit message to be compared against the expected value.

Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
 t/t7502-commit.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index cbd7a45..9040f8a 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -181,8 +181,8 @@ 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 &&
+	git commit --cleanup=verbatim --no-status -t expect -a &&
+	git cat-file -p HEAD |sed -e "1,/^\$/d" >actual &&
 	test_cmp expect actual
 
 '
-- 
1.8.1.3.638.g372f416.dirty
Next: Brandon Casey
Message 1 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.