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" && } >"$actual" &&
if test -f "$expect" if test -f "$expect"
then then
test_cmp "$expect" "$actual" && case $cmd in
*format-patch* | *-stat*)
test_i18ncmp "$expect" "$actual";;
*)
test_cmp "$expect" "$actual";;
esac &&
rm -f "$actual" rm -f "$actual"
else else
# this is to help developing new tests. # 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 cat > expect << EOF
---
file | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/file b/file
index 40f36c6..2dc5c23 100644 index 40f36c6..2dc5c23 100644
--- a/file --- a/file
+++ b/file +++ b/file
@ -537,7 +532,9 @@ EOF
test_expect_success 'format-patch respects -U' ' test_expect_success 'format-patch respects -U' '
git format-patch -U4 -2 && 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 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_cmp expect actual
' '
test_expect_success TABS_IN_FILENAMES 'setup expected files' ' test_expect_success TABS_IN_FILENAMES 'git diff --numstat -M HEAD' '
cat >expect <<\EOF cat >expect <<-\EOF &&
pathname.1 => "Rpathname\twith HT.0" | 0 0 0 pathname.1 => "Rpathname\twith HT.0"
pathname.3 => "Rpathname\nwith LF.0" | 0 0 0 pathname.3 => "Rpathname\nwith LF.0"
"pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0 0 0 "pathname\twith HT.3" => "Rpathname\nwith LF.1"
pathname.2 => Rpathname with SP.0 | 0 0 0 pathname.2 => Rpathname with SP.0
"pathname\twith HT.2" => Rpathname with SP.1 | 0 0 0 "pathname\twith HT.2" => Rpathname with SP.1
pathname.0 => Rpathname.0 | 0 0 0 pathname.0 => Rpathname.0
"pathname\twith HT.0" => Rpathname.1 | 0 0 0 "pathname\twith HT.0" => Rpathname.1
7 files changed, 0 insertions(+), 0 deletions(-) EOF
EOF git diff --numstat -M HEAD >actual &&
'
test_expect_success TABS_IN_FILENAMES 'git diff --stat -M HEAD' '
git diff --stat -M HEAD >actual &&
test_cmp expect 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 test_done

View file

@ -91,7 +91,11 @@ EOF
test_expect_success 'diffstat does not run textconv' ' test_expect_success 'diffstat does not run textconv' '
echo file diff=fail >.gitattributes && echo file diff=fail >.gitattributes &&
git diff --stat HEAD^ HEAD >actual && 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 # restore working setup
echo file diff=foo >.gitattributes 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 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 && git diff -B --stat --summary >diff &&
grep "Bin" diff && grep "Bin" diff &&
grep "0 insertions.*0 deletions" diff && test_i18ngrep "0 insertions.*0 deletions" diff &&
grep " rewrite file" diff grep " rewrite file" diff
' '

View file

@ -23,9 +23,8 @@ test_expect_success 'move the files into a "sub" directory' '
' '
cat > expected <<\EOF cat > expected <<\EOF
bar => sub/bar | Bin 5 -> 5 bytes - - bar => sub/bar
foo => sub/foo | 0 0 0 foo => sub/foo
2 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/bar b/sub/bar diff --git a/bar b/sub/bar
similarity index 100% similarity index 100%
@ -38,7 +37,8 @@ rename to sub/foo
EOF EOF
test_expect_success 'git show -C -C report renames' ' 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 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() { check_stat() {
expect=$1; shift expect=$1; shift
cat >expected <<EOF cat >expected <<EOF
@ -37,7 +49,7 @@ cat >expected <<EOF
EOF EOF
test_expect_success "--stat $*" " test_expect_success "--stat $*" "
git diff --stat $* HEAD^ >actual && 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 file2 --relative=subdir check_$type file2 --relative=subdir
check_$type dir/file2 --relative=sub check_$type dir/file2 --relative=sub

View file

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