diff --stat: use less columns for change counts
[git/mingw.git] / t / t4052-stat-output.sh
blob4bdc7d43765352c9e6ab3c04f0432abbb55b8bf4
1 #!/bin/sh
3 # Copyright (c) 2012 Zbigniew Jędrzejewski-Szmek
6 test_description='test --stat output of various commands'
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-terminal.sh
11 # 120 character name
12 name=aaaaaaaaaa
13 name=$name$name$name$name$name$name$name$name$name$name$name$name
14 test_expect_success 'preparation' '
15 >"$name" &&
16 git add "$name" &&
17 git commit -m message &&
18 echo a >"$name" &&
19 git commit -m message "$name"
22 while read cmd args
24 cat >expect <<-'EOF'
25 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
26 EOF
27 test_expect_success "$cmd: small change with long name gives more space to the name" '
28 git $cmd $args >output &&
29 grep " | " output >actual &&
30 test_cmp expect actual
33 cat >expect <<-'EOF'
34 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
35 EOF
36 test_expect_success "$cmd --stat=width: a long name is given more room when the bar is short" '
37 git $cmd $args --stat=40 >output &&
38 grep " | " output >actual &&
39 test_cmp expect actual
42 test_expect_success "$cmd --stat-width=width with long name" '
43 git $cmd $args --stat-width=40 >output &&
44 grep " | " output >actual &&
45 test_cmp expect actual
48 cat >expect <<-'EOF'
49 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
50 EOF
51 test_expect_success "$cmd --stat=...,name-width with long name" '
52 git $cmd $args --stat=60,30 >output &&
53 grep " | " output >actual &&
54 test_cmp expect actual
57 test_expect_success "$cmd --stat-name-width with long name" '
58 git $cmd $args --stat-name-width=30 >output &&
59 grep " | " output >actual &&
60 test_cmp expect actual
62 done <<\EOF
63 format-patch -1 --stdout
64 diff HEAD^ HEAD --stat
65 show --stat
66 log -1 --stat
67 EOF
70 test_expect_success 'preparation for big change tests' '
71 >abcd &&
72 git add abcd &&
73 git commit -m message &&
74 i=0 &&
75 while test $i -lt 1000
77 echo $i && i=$(($i + 1))
78 done >abcd &&
79 git commit -m message abcd
82 cat >expect80 <<'EOF'
83 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84 EOF
86 cat >expect200 <<'EOF'
87 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
88 EOF
90 while read verb expect cmd args
92 test_expect_success "$cmd $verb COLUMNS (big change)" '
93 COLUMNS=200 git $cmd $args >output
94 grep " | " output >actual &&
95 test_cmp "$expect" actual
97 done <<\EOF
98 ignores expect80 format-patch -1 --stdout
99 respects expect200 diff HEAD^ HEAD --stat
100 respects expect200 show --stat
101 respects expect200 log -1 --stat
104 cat >expect40 <<'EOF'
105 abcd | 1000 ++++++++++++++++++++++++++
108 while read verb expect cmd args
110 test_expect_success "$cmd $verb not enough COLUMNS (big change)" '
111 COLUMNS=40 git $cmd $args >output
112 grep " | " output >actual &&
113 test_cmp "$expect" actual
116 test_expect_success "$cmd $verb statGraphWidth config" '
117 git -c diff.statGraphWidth=26 $cmd $args >output
118 grep " | " output >actual &&
119 test_cmp "$expect" actual
121 done <<\EOF
122 ignores expect80 format-patch -1 --stdout
123 respects expect40 diff HEAD^ HEAD --stat
124 respects expect40 show --stat
125 respects expect40 log -1 --stat
129 cat >expect <<'EOF'
130 abcd | 1000 ++++++++++++++++++++++++++
132 while read cmd args
134 test_expect_success "$cmd --stat=width with big change" '
135 git $cmd $args --stat=40 >output
136 grep " | " output >actual &&
137 test_cmp expect actual
140 test_expect_success "$cmd --stat-width=width with big change" '
141 git $cmd $args --stat-width=40 >output
142 grep " | " output >actual &&
143 test_cmp expect actual
146 test_expect_success "$cmd --stat-graph--width with big change" '
147 git $cmd $args --stat-graph-width=26 >output
148 grep " | " output >actual &&
149 test_cmp expect actual
151 done <<\EOF
152 format-patch -1 --stdout
153 diff HEAD^ HEAD --stat
154 show --stat
155 log -1 --stat
158 test_expect_success 'preparation for long filename tests' '
159 cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
160 git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
161 git commit -m message
164 cat >expect <<'EOF'
165 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
167 while read cmd args
169 test_expect_success "$cmd --stat=width with big change is more balanced" '
170 git $cmd $args --stat-width=60 >output &&
171 grep " | " output >actual &&
172 test_cmp expect actual
174 done <<\EOF
175 format-patch -1 --stdout
176 diff HEAD^ HEAD --stat
177 show --stat
178 log -1 --stat
181 cat >expect80 <<'EOF'
182 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
184 cat >expect200 <<'EOF'
185 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
187 while read verb expect cmd args
189 test_expect_success "$cmd $verb COLUMNS (long filename)" '
190 COLUMNS=200 git $cmd $args >output
191 grep " | " output >actual &&
192 test_cmp "$expect" actual
194 done <<\EOF
195 ignores expect80 format-patch -1 --stdout
196 respects expect200 diff HEAD^ HEAD --stat
197 respects expect200 show --stat
198 respects expect200 log -1 --stat
201 cat >expect <<'EOF'
202 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
204 test_expect_success 'merge --stat respects COLUMNS (big change)' '
205 git checkout -b branch HEAD^^ &&
206 COLUMNS=100 git merge --stat --no-ff master^ >output &&
207 grep " | " output >actual
208 test_cmp expect actual
211 cat >expect <<'EOF'
212 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
214 test_expect_success 'merge --stat respects COLUMNS (long filename)' '
215 COLUMNS=100 git merge --stat --no-ff master >output &&
216 grep " | " output >actual
217 test_cmp expect actual
220 test_done