cocci: apply "pending" index-compatibility to "t/helper/*.c"
[git/debian.git] / t / t4049-diff-stat-count.sh
blob0a4fc735d44ad525f0924b86e355d4a257650a62
1 #!/bin/sh
2 # Copyright (c) 2011, Google Inc.
4 test_description='diff --stat-count'
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
9 test_expect_success 'setup' '
10 >a &&
11 >b &&
12 >c &&
13 >d &&
14 git add a b c d &&
15 git commit -m initial
18 test_expect_success 'mode-only change show as a 0-line change' '
19 git reset --hard &&
20 test_chmod +x b d &&
21 echo a >a &&
22 echo c >c &&
23 cat >expect <<-\EOF &&
24 a | 1 +
25 b | 0
26 ...
27 4 files changed, 2 insertions(+)
28 EOF
29 git diff --stat --stat-count=2 HEAD >actual &&
30 test_cmp expect actual
33 test_expect_success 'binary changes do not count in lines' '
34 git reset --hard &&
35 echo a >a &&
36 echo c >c &&
37 cat "$TEST_DIRECTORY"/test-binary-1.png >d &&
38 cat >expect <<-\EOF &&
39 a | 1 +
40 c | 1 +
41 ...
42 3 files changed, 2 insertions(+)
43 EOF
44 git diff --stat --stat-count=2 >actual &&
45 test_cmp expect actual
48 test_expect_success 'exclude unmerged entries from total file count' '
49 git reset --hard &&
50 echo a >a &&
51 echo b >b &&
52 git ls-files -s a >x &&
53 git rm -f d &&
54 for stage in 1 2 3
56 sed -e "s/ 0 a/ $stage d/" x || return 1
57 done |
58 git update-index --index-info &&
59 echo d >d &&
60 cat >expect <<-\EOF &&
61 a | 1 +
62 b | 1 +
63 ...
64 3 files changed, 3 insertions(+)
65 EOF
66 git diff --stat --stat-count=2 >actual &&
67 test_cmp expect actual
70 test_done