t4052: test --stat output with --graph
[git/jnareb-git.git] / t / t4052-stat-output.sh
blobda14984585f047f8b43dc20d5ec66d98e8b21c2e
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 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 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 ...aaaaaaaaaaaaaaaaaaaaaaaaaa | 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
85 cat >expect80-graph <<'EOF'
86 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87 EOF
88 cat >expect200 <<'EOF'
89 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90 EOF
91 cat >expect200-graph <<'EOF'
92 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93 EOF
94 while read verb expect cmd args
96 test_expect_success "$cmd $verb COLUMNS (big change)" '
97 COLUMNS=200 git $cmd $args >output
98 grep " | " output >actual &&
99 test_cmp "$expect" actual
102 test "$cmd" != diff || continue
104 test_expect_success "$cmd --graph $verb COLUMNS (big change)" '
105 COLUMNS=200 git $cmd $args --graph >output
106 grep " | " output >actual &&
107 test_cmp "$expect-graph" actual
109 done <<\EOF
110 ignores expect80 format-patch -1 --stdout
111 respects expect200 diff HEAD^ HEAD --stat
112 respects expect200 show --stat
113 respects expect200 log -1 --stat
116 cat >expect40 <<'EOF'
117 abcd | 1000 ++++++++++++++++++++++++++
119 cat >expect40-graph <<'EOF'
120 | abcd | 1000 ++++++++++++++++++++++++++
122 while read verb expect cmd args
124 test_expect_success "$cmd $verb not enough COLUMNS (big change)" '
125 COLUMNS=40 git $cmd $args >output
126 grep " | " output >actual &&
127 test_cmp "$expect" actual
130 test_expect_success "$cmd $verb statGraphWidth config" '
131 git -c diff.statGraphWidth=26 $cmd $args >output
132 grep " | " output >actual &&
133 test_cmp "$expect" actual
136 test "$cmd" != diff || continue
138 test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" '
139 COLUMNS=40 git $cmd $args --graph >output
140 grep " | " output >actual &&
141 test_cmp "$expect-graph" actual
144 test_expect_success "$cmd --graph $verb statGraphWidth config" '
145 git -c diff.statGraphWidth=26 $cmd $args --graph >output
146 grep " | " output >actual &&
147 test_cmp "$expect-graph" actual
149 done <<\EOF
150 ignores expect80 format-patch -1 --stdout
151 respects expect40 diff HEAD^ HEAD --stat
152 respects expect40 show --stat
153 respects expect40 log -1 --stat
157 cat >expect <<'EOF'
158 abcd | 1000 ++++++++++++++++++++++++++
160 cat >expect-graph <<'EOF'
161 | abcd | 1000 ++++++++++++++++++++++++++
163 while read cmd args
165 test_expect_success "$cmd --stat=width with big change" '
166 git $cmd $args --stat=40 >output
167 grep " | " output >actual &&
168 test_cmp expect actual
171 test_expect_success "$cmd --stat-width=width with big change" '
172 git $cmd $args --stat-width=40 >output
173 grep " | " output >actual &&
174 test_cmp expect actual
177 test_expect_success "$cmd --stat-graph-width with big change" '
178 git $cmd $args --stat-graph-width=26 >output
179 grep " | " output >actual &&
180 test_cmp expect actual
183 test "$cmd" != diff || continue
185 test_expect_success "$cmd --stat-width=width --graph with big change" '
186 git $cmd $args --stat-width=40 --graph >output
187 grep " | " output >actual &&
188 test_cmp expect-graph actual
191 test_expect_success "$cmd --stat-graph-width --graph with big change" '
192 git $cmd $args --stat-graph-width=26 --graph >output
193 grep " | " output >actual &&
194 test_cmp expect-graph actual
196 done <<\EOF
197 format-patch -1 --stdout
198 diff HEAD^ HEAD --stat
199 show --stat
200 log -1 --stat
203 test_expect_success 'preparation for long filename tests' '
204 cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
205 git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
206 git commit -m message
209 cat >expect <<'EOF'
210 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
212 cat >expect-graph <<'EOF'
213 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
215 while read cmd args
217 test_expect_success "$cmd --stat=width with big change is more balanced" '
218 git $cmd $args --stat-width=60 >output &&
219 grep " | " output >actual &&
220 test_cmp expect actual
223 test "$cmd" != diff || continue
225 test_expect_success "$cmd --stat=width --graph with big change is balanced" '
226 git $cmd $args --stat-width=60 --graph >output &&
227 grep " | " output >actual &&
228 test_cmp expect-graph actual
230 done <<\EOF
231 format-patch -1 --stdout
232 diff HEAD^ HEAD --stat
233 show --stat
234 log -1 --stat
237 cat >expect80 <<'EOF'
238 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
240 cat >expect80-graph <<'EOF'
241 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
243 cat >expect200 <<'EOF'
244 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
246 cat >expect200-graph <<'EOF'
247 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
249 while read verb expect cmd args
251 test_expect_success "$cmd $verb COLUMNS (long filename)" '
252 COLUMNS=200 git $cmd $args >output
253 grep " | " output >actual &&
254 test_cmp "$expect" actual
257 test "$cmd" != diff || continue
259 test_expect_success "$cmd --graph $verb COLUMNS (long filename)" '
260 COLUMNS=200 git $cmd $args --graph >output
261 grep " | " output >actual &&
262 test_cmp "$expect-graph" actual
264 done <<\EOF
265 ignores expect80 format-patch -1 --stdout
266 respects expect200 diff HEAD^ HEAD --stat
267 respects expect200 show --stat
268 respects expect200 log -1 --stat
271 cat >expect <<'EOF'
272 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
274 test_expect_success 'merge --stat respects COLUMNS (big change)' '
275 git checkout -b branch HEAD^^ &&
276 COLUMNS=100 git merge --stat --no-ff master^ >output &&
277 grep " | " output >actual
278 test_cmp expect actual
281 cat >expect <<'EOF'
282 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
284 test_expect_success 'merge --stat respects COLUMNS (long filename)' '
285 COLUMNS=100 git merge --stat --no-ff master >output &&
286 grep " | " output >actual
287 test_cmp expect actual
290 test_done