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 <gitster@pobox.com>

Junio C Hamano committed Nov 27, 2012 at 12:55 UTC 9667ccbc8c513458cba0606644150eccb8a0c86b
1 file changed +45 -1
t/t4049-diff-stat-count.sh
+45 -1
@@ -4,12 +4,17 @@
4 test_description='diff --stat-count'
5 . ./test-lib.sh
6
7 -test_expect_success setup '
7 +test_expect_success 'setup' '
8 >a &&
9 >b &&
10 >c &&
11 >d &&
12 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 &&
18 chmod +x c d &&
19 echo a >a &&
20 echo b >b &&
@@ -23,4 +28,43 @@ test_expect_success setup '
28 test_i18ncmp expect actual
29 '
30
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 +
70 test_done