diff --stat: move the "total count" logic to the last loop
[git/mjg.git] / t / t4049-diff-stat-count.sh
blob70ee0736813fd4db389f996080bfdb28515ffc8b
1 #!/bin/sh
2 # Copyright (c) 2011, Google Inc.
4 test_description='diff --stat-count'
5 . ./test-lib.sh
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
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 &&
21 cat >expect <<-\EOF
22 a | 1 +
23 b | 1 +
24 ...
25 4 files changed, 2 insertions(+)
26 EOF
27 git diff --stat --stat-count=2 >actual &&
28 test_i18ncmp expect actual
31 test_expect_success '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
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
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
70 test_done