1#!/bin/sh
2# Copyright (c) 2011, Google Inc.
3
4test_description='diff --stat-count'
5. ./test-lib.sh
6
7test_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
16test_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
29'
30
31test_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
45'
46
47test_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
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
70test_done