diffstat summary line varies by locale: miscellany

These changes are in the same spirit as the six patches that precede them, but they haven't been split into individually justifiable patches yet. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Mar 13, 2012 at 00:05 UTC 6dd88832e77ad7c0c7f82522d3741b5b7bf62fbd
8 files changed +96 -64
t/t4013-diff-various.sh
+6 -1
@@ -128,7 +128,12 @@ do
128 } >"$actual" &&
129 if test -f "$expect"
130 then
131 - test_cmp "$expect" "$actual" &&
131 + case $cmd in
132 + *format-patch* | *-stat*)
133 + test_i18ncmp "$expect" "$actual";;
134 + *)
135 + test_cmp "$expect" "$actual";;
136 + esac &&
137 rm -f "$actual"
138 else
139 # this is to help developing new tests.
t/t4014-format-patch.sh
+3 -6
@@ -518,11 +518,6 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
518 '
519
520 cat > expect << EOF
521 ----
522 - file | 16 ++++++++++++++++
523 - 1 file changed, 16 insertions(+)
524 -
525 -diff --git a/file b/file
521 index 40f36c6..2dc5c23 100644
522 --- a/file
523 +++ b/file
@@ -537,7 +532,9 @@ EOF
532 test_expect_success 'format-patch respects -U' '
533
534 git format-patch -U4 -2 &&
540 - sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
535 + sed -e "1,/^diff/d" -e "/^+5/q" \
536 + <0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
537 + >output &&
538 test_cmp expect output
539
540 '
t/t4016-diff-quote.sh
+23 -12
@@ -57,22 +57,33 @@ test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' '
57 test_cmp expect actual
58 '
59
60 -test_expect_success TABS_IN_FILENAMES 'setup expected files' '
61 -cat >expect <<\EOF
62 - pathname.1 => "Rpathname\twith HT.0" | 0
63 - pathname.3 => "Rpathname\nwith LF.0" | 0
64 - "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
65 - pathname.2 => Rpathname with SP.0 | 0
66 - "pathname\twith HT.2" => Rpathname with SP.1 | 0
67 - pathname.0 => Rpathname.0 | 0
68 - "pathname\twith HT.0" => Rpathname.1 | 0
69 - 7 files changed, 0 insertions(+), 0 deletions(-)
70 -EOF
60 +test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
61 + cat >expect <<-\EOF &&
62 + 0 0 pathname.1 => "Rpathname\twith HT.0"
63 + 0 0 pathname.3 => "Rpathname\nwith LF.0"
64 + 0 0 "pathname\twith HT.3" => "Rpathname\nwith LF.1"
65 + 0 0 pathname.2 => Rpathname with SP.0
66 + 0 0 "pathname\twith HT.2" => Rpathname with SP.1
67 + 0 0 pathname.0 => Rpathname.0
68 + 0 0 "pathname\twith HT.0" => Rpathname.1
69 + EOF
70 + git diff --numstat -M HEAD >actual &&
71 + test_cmp expect actual
72 '
73
74 test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
75 + cat >expect <<-\EOF &&
76 + pathname.1 => "Rpathname\twith HT.0" | 0
77 + pathname.3 => "Rpathname\nwith LF.0" | 0
78 + "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
79 + pathname.2 => Rpathname with SP.0 | 0
80 + "pathname\twith HT.2" => Rpathname with SP.1 | 0
81 + pathname.0 => Rpathname.0 | 0
82 + "pathname\twith HT.0" => Rpathname.1 | 0
83 + 7 files changed, 0 insertions(+), 0 deletions(-)
84 + EOF
85 git diff --stat -M HEAD >actual &&
75 - test_cmp expect actual
86 + test_i18ncmp expect actual
87 '
88
89 test_done
t/t4030-diff-textconv.sh
+5 -1
@@ -91,7 +91,11 @@ EOF
91 test_expect_success 'diffstat does not run textconv' '
92 echo file diff=fail >.gitattributes &&
93 git diff --stat HEAD^ HEAD >actual &&
94 - test_cmp expect.stat actual
94 + test_i18ncmp expect.stat actual &&
95 +
96 + head -n1 <expect.stat >expect.line1 &&
97 + head -n1 <actual >actual.line1 &&
98 + test_cmp expect.line1 actual.line1
99 '
100 # restore working setup
101 echo file diff=foo >.gitattributes
t/t4031-diff-rewrite-binary.sh
+8 -2
@@ -44,10 +44,16 @@ test_expect_success 'rewrite diff can show binary patch' '
44 grep "GIT binary patch" diff
45 '
46
47 -test_expect_success 'rewrite diff --stat shows binary changes' '
47 +test_expect_success 'rewrite diff --numstat shows binary changes' '
48 + git diff -B --numstat --summary >diff &&
49 + grep -e "- - " diff &&
50 + grep " rewrite file" diff
51 +'
52 +
53 +test_expect_success 'diff --stat counts binary rewrite as 0 lines' '
54 git diff -B --stat --summary >diff &&
55 grep "Bin" diff &&
50 - grep "0 insertions.*0 deletions" diff &&
56 + test_i18ngrep "0 insertions.*0 deletions" diff &&
57 grep " rewrite file" diff
58 '
59
t/t4043-diff-rename-binary.sh
+4 -4
@@ -23,9 +23,8 @@ test_expect_success 'move the files into a "sub" directory' '
23 '
24
25 cat > expected <<\EOF
26 - bar => sub/bar | Bin 5 -> 5 bytes
27 - foo => sub/foo | 0
28 - 2 files changed, 0 insertions(+), 0 deletions(-)
26 +- - bar => sub/bar
27 +0 0 foo => sub/foo
28
29 diff --git a/bar b/sub/bar
30 similarity index 100%
@@ -38,7 +37,8 @@ rename to sub/foo
37 EOF
38
39 test_expect_success 'git show -C -C report renames' '
41 - git show -C -C --raw --binary --stat | tail -n 12 > current &&
40 + git show -C -C --raw --binary --numstat >patch-with-stat &&
41 + tail -n 11 patch-with-stat >current &&
42 test_cmp expected current
43 '
44
t/t4045-diff-relative.sh
+14 -2
@@ -29,6 +29,18 @@ test_expect_success "-p $*" "
29 "
30 }
31
32 +check_numstat() {
33 +expect=$1; shift
34 +cat >expected <<EOF
35 +1 0 $expect
36 +EOF
37 +test_expect_success "--numstat $*" "
38 + echo '1 0 $expect' >expected &&
39 + git diff --numstat $* HEAD^ >actual &&
40 + test_cmp expected actual
41 +"
42 +}
43 +
44 check_stat() {
45 expect=$1; shift
46 cat >expected <<EOF
@@ -37,7 +49,7 @@ cat >expected <<EOF
49 EOF
50 test_expect_success "--stat $*" "
51 git diff --stat $* HEAD^ >actual &&
40 - test_cmp expected actual
52 + test_i18ncmp expected actual
53 "
54 }
55
@@ -52,7 +64,7 @@ test_expect_success "--raw $*" "
64 "
65 }
66
55 -for type in diff stat raw; do
67 +for type in diff numstat stat raw; do
68 check_$type file2 --relative=subdir/
69 check_$type file2 --relative=subdir
70 check_$type dir/file2 --relative=sub
t/t4047-diff-dirstat.sh
+33 -36
@@ -252,50 +252,47 @@ EOF
252 '
253
254 cat <<EOF >expect_diff_stat
255 - changed/text | 2 +-
256 - dst/copy/changed/text | 10 ++++++++++
257 - dst/copy/rearranged/text | 10 ++++++++++
258 - dst/copy/unchanged/text | 10 ++++++++++
259 - dst/move/changed/text | 10 ++++++++++
260 - dst/move/rearranged/text | 10 ++++++++++
261 - dst/move/unchanged/text | 10 ++++++++++
262 - rearranged/text | 2 +-
263 - src/move/changed/text | 10 ----------
264 - src/move/rearranged/text | 10 ----------
265 - src/move/unchanged/text | 10 ----------
266 - 11 files changed, 62 insertions(+), 32 deletions(-)
255 +1 1 changed/text
256 +10 0 dst/copy/changed/text
257 +10 0 dst/copy/rearranged/text
258 +10 0 dst/copy/unchanged/text
259 +10 0 dst/move/changed/text
260 +10 0 dst/move/rearranged/text
261 +10 0 dst/move/unchanged/text
262 +1 1 rearranged/text
263 +0 10 src/move/changed/text
264 +0 10 src/move/rearranged/text
265 +0 10 src/move/unchanged/text
266 EOF
267
268 cat <<EOF >expect_diff_stat_M
270 - changed/text | 2 +-
271 - dst/copy/changed/text | 10 ++++++++++
272 - dst/copy/rearranged/text | 10 ++++++++++
273 - dst/copy/unchanged/text | 10 ++++++++++
274 - {src => dst}/move/changed/text | 2 +-
275 - {src => dst}/move/rearranged/text | 2 +-
276 - {src => dst}/move/unchanged/text | 0
277 - rearranged/text | 2 +-
278 - 8 files changed, 34 insertions(+), 4 deletions(-)
269 +1 1 changed/text
270 +10 0 dst/copy/changed/text
271 +10 0 dst/copy/rearranged/text
272 +10 0 dst/copy/unchanged/text
273 +1 1 {src => dst}/move/changed/text
274 +1 1 {src => dst}/move/rearranged/text
275 +0 0 {src => dst}/move/unchanged/text
276 +1 1 rearranged/text
277 EOF
278
279 cat <<EOF >expect_diff_stat_CC
282 - changed/text | 2 +-
283 - {src => dst}/copy/changed/text | 2 +-
284 - {src => dst}/copy/rearranged/text | 2 +-
285 - {src => dst}/copy/unchanged/text | 0
286 - {src => dst}/move/changed/text | 2 +-
287 - {src => dst}/move/rearranged/text | 2 +-
288 - {src => dst}/move/unchanged/text | 0
289 - rearranged/text | 2 +-
290 - 8 files changed, 6 insertions(+), 6 deletions(-)
291 -EOF
292 -
293 -test_expect_success 'sanity check setup (--stat)' '
294 - git diff --stat HEAD^..HEAD >actual_diff_stat &&
280 +1 1 changed/text
281 +1 1 {src => dst}/copy/changed/text
282 +1 1 {src => dst}/copy/rearranged/text
283 +0 0 {src => dst}/copy/unchanged/text
284 +1 1 {src => dst}/move/changed/text
285 +1 1 {src => dst}/move/rearranged/text
286 +0 0 {src => dst}/move/unchanged/text
287 +1 1 rearranged/text
288 +EOF
289 +
290 +test_expect_success 'sanity check setup (--numstat)' '
291 + git diff --numstat HEAD^..HEAD >actual_diff_stat &&
292 test_cmp expect_diff_stat actual_diff_stat &&
296 - git diff --stat -M HEAD^..HEAD >actual_diff_stat_M &&
293 + git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
294 test_cmp expect_diff_stat_M actual_diff_stat_M &&
298 - git diff --stat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
295 + git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
296 test_cmp expect_diff_stat_CC actual_diff_stat_CC
297 '
298