Skip to content

Commit 9667ccb

Browse files
committed
test: add failing tests for "diff --stat" to t4049
There are a few problems in diff.c around --stat area, partially caused by the recent 74faaa1 (Fix "git diff --stat" for interesting - but empty - file changes, 2012-10-17), and largely caused by the earlier change that introduced when --stat-count was added. Add a few test pieces to t4049 to expose the issues. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 74faaa1 commit 9667ccb

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

t/t4049-diff-stat-count.sh

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
test_description='diff --stat-count'
55
. ./test-lib.sh
66

7-
test_expect_success setup '
7+
test_expect_success 'setup' '
88
>a &&
99
>b &&
1010
>c &&
1111
>d &&
1212
git add a b c d &&
13+
git commit -m initial
14+
'
15+
16+
test_expect_success 'limit output to 2 (simple)' '
17+
git reset --hard &&
1318
chmod +x c d &&
1419
echo a >a &&
1520
echo b >b &&
@@ -23,4 +28,43 @@ test_expect_success setup '
2328
test_i18ncmp expect actual
2429
'
2530

31+
test_expect_failure 'binary changes do not count in lines' '
32+
git reset --hard &&
33+
chmod +x c d &&
34+
echo a >a &&
35+
echo b >b &&
36+
cat "$TEST_DIRECTORY"/test-binary-1.png >d &&
37+
cat >expect <<-\EOF
38+
a | 1 +
39+
b | 1 +
40+
...
41+
4 files changed, 2 insertions(+)
42+
EOF
43+
git diff --stat --stat-count=2 >actual &&
44+
test_i18ncmp expect actual
45+
'
46+
47+
test_expect_failure 'exclude unmerged entries from total file count' '
48+
git reset --hard &&
49+
echo a >a &&
50+
echo b >b &&
51+
git ls-files -s a >x &&
52+
git rm -f d &&
53+
for stage in 1 2 3
54+
do
55+
sed -e "s/ 0 a/ $stage d/" x
56+
done |
57+
git update-index --index-info &&
58+
echo d >d &&
59+
chmod +x c d &&
60+
cat >expect <<-\EOF
61+
a | 1 +
62+
b | 1 +
63+
...
64+
4 files changed, 3 insertions(+)
65+
EOF
66+
git diff --stat --stat-count=2 >actual &&
67+
test_i18ncmp expect actual
68+
'
69+
2670
test_done

0 commit comments

Comments
 (0)