Skip to content

Commit 6dd8883

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2983c0e commit 6dd8883

8 files changed

+96
-64
lines changed

t/t4013-diff-various.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,12 @@ do
128128
} >"$actual" &&
129129
if test -f "$expect"
130130
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 &&
132137
rm -f "$actual"
133138
else
134139
# this is to help developing new tests.

t/t4014-format-patch.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,6 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
518518
'
519519

520520
cat > expect << EOF
521-
---
522-
file | 16 ++++++++++++++++
523-
1 file changed, 16 insertions(+)
524-
525-
diff --git a/file b/file
526521
index 40f36c6..2dc5c23 100644
527522
--- a/file
528523
+++ b/file
@@ -537,7 +532,9 @@ EOF
537532
test_expect_success 'format-patch respects -U' '
538533
539534
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 &&
541538
test_cmp expect output
542539
543540
'

t/t4016-diff-quote.sh

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,33 @@ test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' '
5757
test_cmp expect actual
5858
'
5959

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
7172
'
7273

7374
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
7485
git diff --stat -M HEAD >actual &&
75-
test_cmp expect actual
86+
test_i18ncmp expect actual
7687
'
7788

7889
test_done

t/t4030-diff-textconv.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ EOF
9191
test_expect_success 'diffstat does not run textconv' '
9292
echo file diff=fail >.gitattributes &&
9393
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
9599
'
96100
# restore working setup
97101
echo file diff=foo >.gitattributes

t/t4031-diff-rewrite-binary.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ test_expect_success 'rewrite diff can show binary patch' '
4444
grep "GIT binary patch" diff
4545
'
4646

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' '
4854
git diff -B --stat --summary >diff &&
4955
grep "Bin" diff &&
50-
grep "0 insertions.*0 deletions" diff &&
56+
test_i18ngrep "0 insertions.*0 deletions" diff &&
5157
grep " rewrite file" diff
5258
'
5359

t/t4043-diff-rename-binary.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ test_expect_success 'move the files into a "sub" directory' '
2323
'
2424

2525
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
2928
3029
diff --git a/bar b/sub/bar
3130
similarity index 100%
@@ -38,7 +37,8 @@ rename to sub/foo
3837
EOF
3938

4039
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 &&
4242
test_cmp expected current
4343
'
4444

t/t4045-diff-relative.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ test_expect_success "-p $*" "
2929
"
3030
}
3131

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+
3244
check_stat() {
3345
expect=$1; shift
3446
cat >expected <<EOF
@@ -37,7 +49,7 @@ cat >expected <<EOF
3749
EOF
3850
test_expect_success "--stat $*" "
3951
git diff --stat $* HEAD^ >actual &&
40-
test_cmp expected actual
52+
test_i18ncmp expected actual
4153
"
4254
}
4355

@@ -52,7 +64,7 @@ test_expect_success "--raw $*" "
5264
"
5365
}
5466

55-
for type in diff stat raw; do
67+
for type in diff numstat stat raw; do
5668
check_$type file2 --relative=subdir/
5769
check_$type file2 --relative=subdir
5870
check_$type dir/file2 --relative=sub

t/t4047-diff-dirstat.sh

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -252,50 +252,47 @@ EOF
252252
'
253253

254254
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
267266
EOF
268267

269268
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
279277
EOF
280278

281279
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 &&
295292
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 &&
297294
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 &&
299296
test_cmp expect_diff_stat_CC actual_diff_stat_CC
300297
'
301298

0 commit comments

Comments
 (0)