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>
This commit is contained in:
Jonathan Nieder 2012-03-13 00:05:54 -05:00 committed by Junio C Hamano
parent 2983c0e22a
commit 6dd88832e7
8 changed files with 97 additions and 65 deletions

View File

@ -128,7 +128,12 @@ do
} >"$actual" &&
if test -f "$expect"
then
test_cmp "$expect" "$actual" &&
case $cmd in
*format-patch* | *-stat*)
test_i18ncmp "$expect" "$actual";;
*)
test_cmp "$expect" "$actual";;
esac &&
rm -f "$actual"
else
# this is to help developing new tests.

View File

@ -518,11 +518,6 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
'
cat > expect << EOF
---
file | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/file b/file
index 40f36c6..2dc5c23 100644
--- a/file
+++ b/file
@ -537,7 +532,9 @@ EOF
test_expect_success 'format-patch respects -U' '
git format-patch -U4 -2 &&
sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&
sed -e "1,/^diff/d" -e "/^+5/q" \
<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \
>output &&
test_cmp expect output
'

View File

@ -57,22 +57,33 @@ test_expect_success TABS_IN_FILENAMES 'git diff --summary -M HEAD' '
test_cmp expect actual
'
test_expect_success TABS_IN_FILENAMES 'setup expected files' '
cat >expect <<\EOF
pathname.1 => "Rpathname\twith HT.0" | 0
pathname.3 => "Rpathname\nwith LF.0" | 0
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
pathname.2 => Rpathname with SP.0 | 0
"pathname\twith HT.2" => Rpathname with SP.1 | 0
pathname.0 => Rpathname.0 | 0
"pathname\twith HT.0" => Rpathname.1 | 0
7 files changed, 0 insertions(+), 0 deletions(-)
EOF
'
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
git diff --stat -M HEAD >actual &&
test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
cat >expect <<-\EOF &&
0 0 pathname.1 => "Rpathname\twith HT.0"
0 0 pathname.3 => "Rpathname\nwith LF.0"
0 0 "pathname\twith HT.3" => "Rpathname\nwith LF.1"
0 0 pathname.2 => Rpathname with SP.0
0 0 "pathname\twith HT.2" => Rpathname with SP.1
0 0 pathname.0 => Rpathname.0
0 0 "pathname\twith HT.0" => Rpathname.1
EOF
git diff --numstat -M HEAD >actual &&
test_cmp expect actual
'
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
cat >expect <<-\EOF &&
pathname.1 => "Rpathname\twith HT.0" | 0
pathname.3 => "Rpathname\nwith LF.0" | 0
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
pathname.2 => Rpathname with SP.0 | 0
"pathname\twith HT.2" => Rpathname with SP.1 | 0
pathname.0 => Rpathname.0 | 0
"pathname\twith HT.0" => Rpathname.1 | 0
7 files changed, 0 insertions(+), 0 deletions(-)
EOF
git diff --stat -M HEAD >actual &&
test_i18ncmp expect actual
'
test_done

View File

@ -91,7 +91,11 @@ EOF
test_expect_success 'diffstat does not run textconv' '
echo file diff=fail >.gitattributes &&
git diff --stat HEAD^ HEAD >actual &&
test_cmp expect.stat actual
test_i18ncmp expect.stat actual &&
head -n1 <expect.stat >expect.line1 &&
head -n1 <actual >actual.line1 &&
test_cmp expect.line1 actual.line1
'
# restore working setup
echo file diff=foo >.gitattributes

View File

@ -44,10 +44,16 @@ test_expect_success 'rewrite diff can show binary patch' '
grep "GIT binary patch" diff
'
test_expect_success 'rewrite diff --stat shows binary changes' '
test_expect_success 'rewrite diff --numstat shows binary changes' '
git diff -B --numstat --summary >diff &&
grep -e "- - " diff &&
grep " rewrite file" diff
'
test_expect_success 'diff --stat counts binary rewrite as 0 lines' '
git diff -B --stat --summary >diff &&
grep "Bin" diff &&
grep "0 insertions.*0 deletions" diff &&
test_i18ngrep "0 insertions.*0 deletions" diff &&
grep " rewrite file" diff
'

View File

@ -23,9 +23,8 @@ test_expect_success 'move the files into a "sub" directory' '
'
cat > expected <<\EOF
bar => sub/bar | Bin 5 -> 5 bytes
foo => sub/foo | 0
2 files changed, 0 insertions(+), 0 deletions(-)
- - bar => sub/bar
0 0 foo => sub/foo
diff --git a/bar b/sub/bar
similarity index 100%
@ -38,7 +37,8 @@ rename to sub/foo
EOF
test_expect_success 'git show -C -C report renames' '
git show -C -C --raw --binary --stat | tail -n 12 > current &&
git show -C -C --raw --binary --numstat >patch-with-stat &&
tail -n 11 patch-with-stat >current &&
test_cmp expected current
'

View File

@ -29,6 +29,18 @@ test_expect_success "-p $*" "
"
}
check_numstat() {
expect=$1; shift
cat >expected <<EOF
1 0 $expect
EOF
test_expect_success "--numstat $*" "
echo '1 0 $expect' >expected &&
git diff --numstat $* HEAD^ >actual &&
test_cmp expected actual
"
}
check_stat() {
expect=$1; shift
cat >expected <<EOF
@ -37,7 +49,7 @@ cat >expected <<EOF
EOF
test_expect_success "--stat $*" "
git diff --stat $* HEAD^ >actual &&
test_cmp expected actual
test_i18ncmp expected actual
"
}
@ -52,7 +64,7 @@ test_expect_success "--raw $*" "
"
}
for type in diff stat raw; do
for type in diff numstat stat raw; do
check_$type file2 --relative=subdir/
check_$type file2 --relative=subdir
check_$type dir/file2 --relative=sub

View File

@ -252,50 +252,47 @@ EOF
'
cat <<EOF >expect_diff_stat
changed/text | 2 +-
dst/copy/changed/text | 10 ++++++++++
dst/copy/rearranged/text | 10 ++++++++++
dst/copy/unchanged/text | 10 ++++++++++
dst/move/changed/text | 10 ++++++++++
dst/move/rearranged/text | 10 ++++++++++
dst/move/unchanged/text | 10 ++++++++++
rearranged/text | 2 +-
src/move/changed/text | 10 ----------
src/move/rearranged/text | 10 ----------
src/move/unchanged/text | 10 ----------
11 files changed, 62 insertions(+), 32 deletions(-)
1 1 changed/text
10 0 dst/copy/changed/text
10 0 dst/copy/rearranged/text
10 0 dst/copy/unchanged/text
10 0 dst/move/changed/text
10 0 dst/move/rearranged/text
10 0 dst/move/unchanged/text
1 1 rearranged/text
0 10 src/move/changed/text
0 10 src/move/rearranged/text
0 10 src/move/unchanged/text
EOF
cat <<EOF >expect_diff_stat_M
changed/text | 2 +-
dst/copy/changed/text | 10 ++++++++++
dst/copy/rearranged/text | 10 ++++++++++
dst/copy/unchanged/text | 10 ++++++++++
{src => dst}/move/changed/text | 2 +-
{src => dst}/move/rearranged/text | 2 +-
{src => dst}/move/unchanged/text | 0
rearranged/text | 2 +-
8 files changed, 34 insertions(+), 4 deletions(-)
1 1 changed/text
10 0 dst/copy/changed/text
10 0 dst/copy/rearranged/text
10 0 dst/copy/unchanged/text
1 1 {src => dst}/move/changed/text
1 1 {src => dst}/move/rearranged/text
0 0 {src => dst}/move/unchanged/text
1 1 rearranged/text
EOF
cat <<EOF >expect_diff_stat_CC
changed/text | 2 +-
{src => dst}/copy/changed/text | 2 +-
{src => dst}/copy/rearranged/text | 2 +-
{src => dst}/copy/unchanged/text | 0
{src => dst}/move/changed/text | 2 +-
{src => dst}/move/rearranged/text | 2 +-
{src => dst}/move/unchanged/text | 0
rearranged/text | 2 +-
8 files changed, 6 insertions(+), 6 deletions(-)
1 1 changed/text
1 1 {src => dst}/copy/changed/text
1 1 {src => dst}/copy/rearranged/text
0 0 {src => dst}/copy/unchanged/text
1 1 {src => dst}/move/changed/text
1 1 {src => dst}/move/rearranged/text
0 0 {src => dst}/move/unchanged/text
1 1 rearranged/text
EOF
test_expect_success 'sanity check setup (--stat)' '
git diff --stat HEAD^..HEAD >actual_diff_stat &&
test_expect_success 'sanity check setup (--numstat)' '
git diff --numstat HEAD^..HEAD >actual_diff_stat &&
test_cmp expect_diff_stat actual_diff_stat &&
git diff --stat -M HEAD^..HEAD >actual_diff_stat_M &&
git diff --numstat -M HEAD^..HEAD >actual_diff_stat_M &&
test_cmp expect_diff_stat_M actual_diff_stat_M &&
git diff --stat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
git diff --numstat -C -C HEAD^..HEAD >actual_diff_stat_CC &&
test_cmp expect_diff_stat_CC actual_diff_stat_CC
'