merge-one-file: compute empty blob object ID
[git/debian.git] / t / t4052-stat-output.sh
blob6e2cf933f761683781525b36330e38c758aaabd6
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 cat >expect72 <<-'EOF'
23 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
24 EOF
25 test_expect_success "format-patch: small change with long name gives more space to the name" '
26 git format-patch -1 --stdout >output &&
27 grep " | " output >actual &&
28 test_cmp expect72 actual
31 while read cmd args
33 cat >expect80 <<-'EOF'
34 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
35 EOF
36 test_expect_success "$cmd: small change with long name gives more space to the name" '
37 git $cmd $args >output &&
38 grep " | " output >actual &&
39 test_cmp expect80 actual
41 done <<\EOF
42 diff HEAD^ HEAD --stat
43 show --stat
44 log -1 --stat
45 EOF
47 while read cmd args
49 cat >expect <<-'EOF'
50 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
51 EOF
52 test_expect_success "$cmd --stat=width: a long name is given more room when the bar is short" '
53 git $cmd $args --stat=40 >output &&
54 grep " | " output >actual &&
55 test_cmp expect actual
58 test_expect_success "$cmd --stat-width=width with long name" '
59 git $cmd $args --stat-width=40 >output &&
60 grep " | " output >actual &&
61 test_cmp expect actual
64 cat >expect <<-'EOF'
65 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
66 EOF
67 test_expect_success "$cmd --stat=...,name-width with long name" '
68 git $cmd $args --stat=60,30 >output &&
69 grep " | " output >actual &&
70 test_cmp expect actual
73 test_expect_success "$cmd --stat-name-width with long name" '
74 git $cmd $args --stat-name-width=30 >output &&
75 grep " | " output >actual &&
76 test_cmp expect actual
78 done <<\EOF
79 format-patch -1 --stdout
80 diff HEAD^ HEAD --stat
81 show --stat
82 log -1 --stat
83 EOF
86 test_expect_success 'preparation for big change tests' '
87 >abcd &&
88 git add abcd &&
89 git commit -m message &&
90 i=0 &&
91 while test $i -lt 1000
93 echo $i && i=$(($i + 1))
94 done >abcd &&
95 git commit -m message abcd
98 cat >expect72 <<'EOF'
99 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
101 cat >expect72-graph <<'EOF'
102 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
104 cat >expect200 <<'EOF'
105 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
107 cat >expect200-graph <<'EOF'
108 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110 while read verb expect cmd args
112 test_expect_success "$cmd $verb COLUMNS (big change)" '
113 COLUMNS=200 git $cmd $args >output &&
114 grep " | " output >actual &&
115 test_cmp "$expect" actual
118 case "$cmd" in diff|show) continue;; esac
120 test_expect_success "$cmd --graph $verb COLUMNS (big change)" '
121 COLUMNS=200 git $cmd $args --graph >output &&
122 grep " | " output >actual &&
123 test_cmp "$expect-graph" actual
125 done <<\EOF
126 ignores expect72 format-patch -1 --stdout
127 respects expect200 diff HEAD^ HEAD --stat
128 respects expect200 show --stat
129 respects expect200 log -1 --stat
132 cat >expect40 <<'EOF'
133 abcd | 1000 ++++++++++++++++++++++++++
135 cat >expect40-graph <<'EOF'
136 | abcd | 1000 ++++++++++++++++++++++++
138 while read verb expect cmd args
140 test_expect_success "$cmd $verb not enough COLUMNS (big change)" '
141 COLUMNS=40 git $cmd $args >output &&
142 grep " | " output >actual &&
143 test_cmp "$expect" actual
146 case "$cmd" in diff|show) continue;; esac
148 test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" '
149 COLUMNS=40 git $cmd $args --graph >output &&
150 grep " | " output >actual &&
151 test_cmp "$expect-graph" actual
153 done <<\EOF
154 ignores expect72 format-patch -1 --stdout
155 respects expect40 diff HEAD^ HEAD --stat
156 respects expect40 show --stat
157 respects expect40 log -1 --stat
160 cat >expect40 <<'EOF'
161 abcd | 1000 ++++++++++++++++++++++++++
163 cat >expect40-graph <<'EOF'
164 | abcd | 1000 ++++++++++++++++++++++++++
166 while read verb expect cmd args
168 test_expect_success "$cmd $verb statGraphWidth config" '
169 git -c diff.statGraphWidth=26 $cmd $args >output &&
170 grep " | " output >actual &&
171 test_cmp "$expect" actual
174 case "$cmd" in diff|show) continue;; esac
176 test_expect_success "$cmd --graph $verb statGraphWidth config" '
177 git -c diff.statGraphWidth=26 $cmd $args --graph >output &&
178 grep " | " output >actual &&
179 test_cmp "$expect-graph" actual
181 done <<\EOF
182 ignores expect72 format-patch -1 --stdout
183 respects expect40 diff HEAD^ HEAD --stat
184 respects expect40 show --stat
185 respects expect40 log -1 --stat
189 cat >expect <<'EOF'
190 abcd | 1000 ++++++++++++++++++++++++++
192 cat >expect-graph <<'EOF'
193 | abcd | 1000 ++++++++++++++++++++++++++
195 while read cmd args
197 test_expect_success "$cmd --stat=width with big change" '
198 git $cmd $args --stat=40 >output &&
199 grep " | " output >actual &&
200 test_cmp expect actual
203 test_expect_success "$cmd --stat-width=width with big change" '
204 git $cmd $args --stat-width=40 >output &&
205 grep " | " output >actual &&
206 test_cmp expect actual
209 test_expect_success "$cmd --stat-graph-width with big change" '
210 git $cmd $args --stat-graph-width=26 >output &&
211 grep " | " output >actual &&
212 test_cmp expect actual
215 case "$cmd" in diff|show) continue;; esac
217 test_expect_success "$cmd --stat-width=width --graph with big change" '
218 git $cmd $args --stat-width=40 --graph >output &&
219 grep " | " output >actual &&
220 test_cmp expect-graph actual
223 test_expect_success "$cmd --stat-graph-width --graph with big change" '
224 git $cmd $args --stat-graph-width=26 --graph >output &&
225 grep " | " output >actual &&
226 test_cmp expect-graph actual
228 done <<\EOF
229 format-patch -1 --stdout
230 diff HEAD^ HEAD --stat
231 show --stat
232 log -1 --stat
235 test_expect_success 'preparation for long filename tests' '
236 cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
237 git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
238 git commit -m message
241 cat >expect <<'EOF'
242 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
244 cat >expect-graph <<'EOF'
245 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
247 while read cmd args
249 test_expect_success "$cmd --stat=width with big change is more balanced" '
250 git $cmd $args --stat-width=60 >output &&
251 grep " | " output >actual &&
252 test_cmp expect actual
255 case "$cmd" in diff|show) continue;; esac
257 test_expect_success "$cmd --stat=width --graph with big change is balanced" '
258 git $cmd $args --stat-width=60 --graph >output &&
259 grep " | " output >actual &&
260 test_cmp expect-graph actual
262 done <<\EOF
263 format-patch -1 --stdout
264 diff HEAD^ HEAD --stat
265 show --stat
266 log -1 --stat
269 cat >expect72 <<'EOF'
270 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++
272 cat >expect72-graph <<'EOF'
273 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++
275 cat >expect200 <<'EOF'
276 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
278 cat >expect200-graph <<'EOF'
279 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
281 while read verb expect cmd args
283 test_expect_success "$cmd $verb COLUMNS (long filename)" '
284 COLUMNS=200 git $cmd $args >output &&
285 grep " | " output >actual &&
286 test_cmp "$expect" actual
289 case "$cmd" in diff|show) continue;; esac
291 test_expect_success "$cmd --graph $verb COLUMNS (long filename)" '
292 COLUMNS=200 git $cmd $args --graph >output &&
293 grep " | " output >actual &&
294 test_cmp "$expect-graph" actual
296 done <<\EOF
297 ignores expect72 format-patch -1 --stdout
298 respects expect200 diff HEAD^ HEAD --stat
299 respects expect200 show --stat
300 respects expect200 log -1 --stat
303 cat >expect1 <<'EOF'
304 ...aaaaaaa | 1000 ++++++
306 cat >expect1-graph <<'EOF'
307 | ...aaaaaaa | 1000 ++++++
309 while read verb expect cmd args
311 test_expect_success COLUMNS_CAN_BE_1 \
312 "$cmd $verb prefix greater than COLUMNS (big change)" '
313 COLUMNS=1 git $cmd $args >output &&
314 grep " | " output >actual &&
315 test_cmp "$expect" actual
318 case "$cmd" in diff|show) continue;; esac
320 test_expect_success COLUMNS_CAN_BE_1 \
321 "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
322 COLUMNS=1 git $cmd $args --graph >output &&
323 grep " | " output >actual &&
324 test_cmp "$expect-graph" actual
326 done <<\EOF
327 ignores expect72 format-patch -1 --stdout
328 respects expect1 diff HEAD^ HEAD --stat
329 respects expect1 show --stat
330 respects expect1 log -1 --stat
333 cat >expect <<'EOF'
334 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
336 test_expect_success 'merge --stat respects COLUMNS (big change)' '
337 git checkout -b branch HEAD^^ &&
338 COLUMNS=100 git merge --stat --no-ff master^ >output &&
339 grep " | " output >actual &&
340 test_cmp expect actual
343 cat >expect <<'EOF'
344 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
346 test_expect_success 'merge --stat respects COLUMNS (long filename)' '
347 COLUMNS=100 git merge --stat --no-ff master >output &&
348 grep " | " output >actual &&
349 test_cmp expect actual
352 test_done