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

[PATCH 2/7] test: use numstat instead of diffstat in funny-names test

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 13, 2012, 04:58 UTC
Message-ID
<20120313045859.GB12550@burratino>
In-Reply-To
<20120313045100.GA12474@burratino>

This test script checks that git's plumbing commands quote filenames with special characters like space, tab, and double-quote appropriately in their input and output.

Since commit v1.7.9.2~13 (Use correct grammar in diffstat summary line, 2012-02-01), the final "1 file changed, 1 insertion(+)" line from diffstats is translatable, meaning tests that rely on exact "git apply --stat" output have to be skipped when git is not configured to produce output in the C locale (for example, when GETTEXT_POISON is enabled). So:

 - Tweak the three "git apply --stat" tests that check "git apply"'s
   input parsing to use --numstat instead.
   --numstat output is more reliable, does not vary with locale, and
   is itself easier to parse.  These tests are mainly about how "git
   apply" parses its input so this should not result in much loss of
   coverage.
 - Add a new "apply --stat" test to check the quoting in --stat output
   format.

This wins back a little of the test coverage lost with the patch "test: use test_i18ncmp to check --stat output" when GETTEXT_POISON is enabled.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
The above description is too noisy.  The intent is:
 The funny-names tests that use "apply --stat" are doing two things:
  - making sure "git apply" can parse a patch that uses funny
    filenames
  - making sure that "git apply --stat" can produce a diffstat
    that uses funny filenames
 Only the latter requires using --stat instead of --numstat.  The
 former is intended for humans and varies by locale, while the
 latter is a format meant to stay more stable between versions
 and thus is more convenient to use in tests.
 This patch makes all but one of these "apply --stat" tests use
 --numstat instead, for the above reasons.

so someone (probably I) will need to consolidate the descriptions in a spare moment.

 t/t3300-funny-names.sh |   27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 644aa219..9114893b 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -171,28 +171,35 @@ cat >expected <<\EOF
 EOF
 '
 
-test_expect_success TABS_IN_FILENAMES 'git diff-tree rename with-funny applied' \
+test_expect_success TABS_IN_FILENAMES 'diffstat for rename with funny chars' \
 	'git diff-index -M -p $t0 |
 	 git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
 	 test_i18ncmp expected current'
 
+test_expect_success TABS_IN_FILENAMES 'numstat for rename with funny chars' \
+	'cat >expected <<-\EOF &&
+	0	0	"tabs\t,\" (dq) and spaces"
+	EOF
+	 git diff-index -M -p $t0 >diff &&
+	 git apply --numstat <diff >current &&
+	 test_cmp expected current'
+
 test_expect_success TABS_IN_FILENAMES 'setup expect' '
 cat > expected <<\EOF
- no-funny
- "tabs\t,\" (dq) and spaces"
- 2 files changed, 3 insertions(+), 3 deletions(-)
+0	3	no-funny
+3	0	"tabs\t,\" (dq) and spaces"
 EOF
 '
 
-test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny applied' \
+test_expect_success TABS_IN_FILENAMES 'numstat without -M for funny rename' \
 	'git diff-index -p $t0 |
-	 git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
-	 test_i18ncmp expected current'
+	 git apply --numstat >current &&
+	 test_cmp expected current'
 
-test_expect_success TABS_IN_FILENAMES 'git apply non-git diff' \
+test_expect_success TABS_IN_FILENAMES 'numstat for non-git funny rename diff' \
 	'git diff-index -p $t0 |
 	 sed -ne "/^[-+@]/p" |
-	 git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
-	 test_i18ncmp expected current'
+	 git apply --numstat >current &&
+	 test_cmp expected current'
 
 test_done
-- 
1.7.9.2
Previous: Jonathan NiederNext: Jonathan Nieder
Message 27 of 32 in “Correct singular form in diff summary line for human interaction”
  1. Correct singular form in diff summary line for human interactionNguyễn Thái Ngọc Duy, Jan 31, 2012
  2. Jonathan NiederJan 31, 2012
  3. Junio C HamanoJan 31, 2012
  4. Nguyen Thai Ngoc DuyFeb 1, 2012
  5. Thomas DickeyFeb 1, 2012
  6. Thomas DickeyFeb 1, 2012
  7. Nguyen Thai Ngoc DuyFeb 1, 2012
  8. Junio C HamanoFeb 1, 2012
  9. Thomas DickeyFeb 1, 2012
  10. Use correct grammar in diffstat summary lineNguyễn Thái Ngọc Duy, Feb 1, 2012
  11. Junio C HamanoFeb 1, 2012
  12. Nguyen Thai Ngoc DuyFeb 2, 2012
  13. Junio C HamanoFeb 2, 2012
  14. Nguyen Thai Ngoc DuyFeb 3, 2012
  15. Junio C HamanoFeb 3, 2012
  16. Jeff KingFeb 3, 2012
  17. Jonathan NiederFeb 1, 2012
  18. i18n: do not define gettext/ngettext in NO_GETTEXT caseJonathan Nieder, Feb 2, 2012
  19. Jonathan NiederFeb 2, 2012
  20. Jonathan NiederFeb 2, 2012
  21. 0/7 tests: diffstat summary line varies by locale (Re: [PATCH v2] Use correct grammar in diffstat summary line)Jonathan Nieder, Mar 13, 2012
  22. 1/7 test: use test_i18ncmp when checking --stat outputJonathan Nieder, Mar 13, 2012
  23. Junio C HamanoMar 13, 2012
  24. Junio C HamanoMar 13, 2012
  25. Jonathan NiederMar 13, 2012
  26. Jonathan NiederMar 13, 2012
  27. 2/7 test: use numstat instead of diffstat in funny-names testJonathan Nieder, Mar 13, 2012
  28. 3/7 test: modernize funny-names test styleJonathan Nieder, Mar 13, 2012
  29. 4/7 test: test cherry-pick functionality and output separatelyJonathan Nieder, Mar 13, 2012
  30. 5/7 test: use --numstat instead of --stat in "git stash show" testsJonathan Nieder, Mar 13, 2012
  31. 6/7 test: use numstat instead of diffstat in binary-diff testJonathan Nieder, Mar 13, 2012
  32. 7/7 diffstat summary line varies by locale: miscellanyJonathan Nieder, Mar 13, 2012

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.