| 1 | #!/bin/sh |
| 2 | # Copyright (c) 2011, Google Inc. |
| 3 | |
| 4 | test_description='diff --stat-count' |
| 5 | |
| 6 | . ./test-lib.sh |
| 7 | |
| 8 | test_expect_success 'setup' ' |
| 9 | >a && |
| 10 | >b && |
| 11 | >c && |
| 12 | >d && |
| 13 | git add a b c d && |
| 14 | git commit -m initial |
| 15 | ' |
| 16 | |
| 17 | test_expect_success 'mode-only change show as a 0-line change' ' |
| 18 | git reset --hard && |
| 19 | test_chmod +x b d && |
| 20 | echo a >a && |
| 21 | echo c >c && |
| 22 | cat >expect <<-\EOF && |
| 23 | a | 1 + |
| 24 | b | 0 |
| 25 | ... |
| 26 | 4 files changed, 2 insertions(+) |
| 27 | EOF |
| 28 | git diff --stat --stat-count=2 HEAD >actual && |
| 29 | test_cmp expect actual |
| 30 | ' |
| 31 | |
| 32 | test_expect_success 'binary changes do not count in lines' ' |
| 33 | git reset --hard && |
| 34 | echo a >a && |
| 35 | echo c >c && |
| 36 | cat "$TEST_DIRECTORY"/test-binary-1.png >d && |
| 37 | cat >expect <<-\EOF && |
| 38 | a | 1 + |
| 39 | c | 1 + |
| 40 | ... |
| 41 | 3 files changed, 2 insertions(+) |
| 42 | EOF |
| 43 | git diff --stat --stat-count=2 >actual && |
| 44 | test_cmp expect actual |
| 45 | ' |
| 46 | |
| 47 | test_expect_success '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 || return 1 |
| 56 | done | |
| 57 | git update-index --index-info && |
| 58 | echo d >d && |
| 59 | cat >expect <<-\EOF && |
| 60 | a | 1 + |
| 61 | b | 1 + |
| 62 | ... |
| 63 | 3 files changed, 3 insertions(+) |
| 64 | EOF |
| 65 | git diff --stat --stat-count=2 >actual && |
| 66 | test_cmp expect actual |
| 67 | ' |
| 68 | |
| 69 | test_done |