]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4049-diff-stat-count.sh
The third batch
[thirdparty/git.git] / t / t4049-diff-stat-count.sh
CommitLineData
e5f85df8
JH
1#!/bin/sh
2# Copyright (c) 2011, Google Inc.
3
4test_description='diff --stat-count'
16d4bd4f
ÆAB
5
6TEST_PASSES_SANITIZE_LEAK=true
e5f85df8
JH
7. ./test-lib.sh
8
9667ccbc 9test_expect_success 'setup' '
e5f85df8
JH
10 >a &&
11 >b &&
12 >c &&
13 >d &&
14 git add a b c d &&
9667ccbc
JH
15 git commit -m initial
16'
17
de909595 18test_expect_success 'mode-only change show as a 0-line change' '
9667ccbc 19 git reset --hard &&
de909595 20 test_chmod +x b d &&
e5f85df8 21 echo a >a &&
de909595 22 echo c >c &&
99094a7a 23 cat >expect <<-\EOF &&
dc801e71 24 a | 1 +
de909595 25 b | 0
74faaa16
LT
26 ...
27 4 files changed, 2 insertions(+)
e5f85df8 28 EOF
de909595 29 git diff --stat --stat-count=2 HEAD >actual &&
1108cea7 30 test_cmp expect actual
e5f85df8
JH
31'
32
a20d3c0d 33test_expect_success 'binary changes do not count in lines' '
9667ccbc 34 git reset --hard &&
9667ccbc 35 echo a >a &&
de909595 36 echo c >c &&
9667ccbc 37 cat "$TEST_DIRECTORY"/test-binary-1.png >d &&
99094a7a 38 cat >expect <<-\EOF &&
9667ccbc 39 a | 1 +
de909595 40 c | 1 +
9667ccbc 41 ...
de909595 42 3 files changed, 2 insertions(+)
9667ccbc
JH
43 EOF
44 git diff --stat --stat-count=2 >actual &&
1108cea7 45 test_cmp expect actual
9667ccbc
JH
46'
47
82dfc2c4 48test_expect_success 'exclude unmerged entries from total file count' '
9667ccbc
JH
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
55 do
cbe1d9d6 56 sed -e "s/ 0 a/ $stage d/" x || return 1
9667ccbc
JH
57 done |
58 git update-index --index-info &&
59 echo d >d &&
99094a7a 60 cat >expect <<-\EOF &&
9667ccbc
JH
61 a | 1 +
62 b | 1 +
63 ...
de909595 64 3 files changed, 3 insertions(+)
9667ccbc
JH
65 EOF
66 git diff --stat --stat-count=2 >actual &&
1108cea7 67 test_cmp expect actual
9667ccbc
JH
68'
69
e5f85df8 70test_done