test: use numstat instead of diffstat in funny-names test

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Mar 12, 2012 at 23:58 UTC e7a8ac3875ef2a6fe10af7f16d034a2b8f218af3
1 file changed +17 -10
t/t3300-funny-names.sh
+17 -10
@@ -171,28 +171,35 @@ cat >expected <<\EOF
171 EOF
172 '
173
174 -test_expect_success TABS_IN_FILENAMES 'git diff-tree rename with-funny applied' \
174 +test_expect_success TABS_IN_FILENAMES 'diffstat for rename with funny chars' \
175 'git diff-index -M -p $t0 |
176 git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
177 test_i18ncmp expected current'
178
179 +test_expect_success TABS_IN_FILENAMES 'numstat for rename with funny chars' \
180 + 'cat >expected <<-\EOF &&
181 + 0 0 "tabs\t,\" (dq) and spaces"
182 + EOF
183 + git diff-index -M -p $t0 >diff &&
184 + git apply --numstat <diff >current &&
185 + test_cmp expected current'
186 +
187 test_expect_success TABS_IN_FILENAMES 'setup expect' '
188 cat > expected <<\EOF
181 - no-funny
182 - "tabs\t,\" (dq) and spaces"
183 - 2 files changed, 3 insertions(+), 3 deletions(-)
189 +0 3 no-funny
190 +3 0 "tabs\t,\" (dq) and spaces"
191 EOF
192 '
193
187 -test_expect_success TABS_IN_FILENAMES 'git diff-tree delete with-funny applied' \
194 +test_expect_success TABS_IN_FILENAMES 'numstat without -M for funny rename' \
195 'git diff-index -p $t0 |
189 - git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
190 - test_i18ncmp expected current'
196 + git apply --numstat >current &&
197 + test_cmp expected current'
198
192 -test_expect_success TABS_IN_FILENAMES 'git apply non-git diff' \
199 +test_expect_success TABS_IN_FILENAMES 'numstat for non-git funny rename diff' \
200 'git diff-index -p $t0 |
201 sed -ne "/^[-+@]/p" |
195 - git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
196 - test_i18ncmp expected current'
202 + git apply --numstat >current &&
203 + test_cmp expected current'
204
205 test_done