Skip to content

Commit

Permalink
diffstat summary line varies by locale: miscellany
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Mar 13, 2012
1 parent 2983c0e commit 6dd8883
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 64 deletions.
7 changes: 6 additions & 1 deletion t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 3 additions & 6 deletions t/t4014-format-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
'
Expand Down
35 changes: 23 additions & 12 deletions t/t4016-diff-quote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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_cmp expect actual
test_i18ncmp expect actual
'

test_done
6 changes: 5 additions & 1 deletion t/t4030-diff-textconv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions t/t4031-diff-rewrite-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'

Expand Down
8 changes: 4 additions & 4 deletions t/t4043-diff-rename-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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%
Expand All @@ -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
'

Expand Down
16 changes: 14 additions & 2 deletions t/t4045-diff-relative.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
"
}

Expand All @@ -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
Expand Down
69 changes: 33 additions & 36 deletions t/t4047-diff-dirstat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(-)
EOF

test_expect_success 'sanity check setup (--stat)' '
git diff --stat HEAD^..HEAD >actual_diff_stat &&
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 (--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
'

Expand Down

0 comments on commit 6dd8883

Please sign in to comment.