3 # Copyright (c) 2012 Zbigniew Jędrzejewski-Szmek
6 test_description
='test --stat output of various commands'
9 .
"$TEST_DIRECTORY"/lib-terminal.sh
13 name
=$name$name$name$name$name$name$name$name$name$name$name$name
14 test_expect_success
'preparation' '
17 git commit -m message &&
19 git commit -m message "$name"
22 cat >expect72
<<-'EOF'
23 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
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
33 cat >expect80
<<-'EOF'
34 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
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
42 diff HEAD^ HEAD
--stat
47 cat >expect
.60 <<-'EOF'
48 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
50 cat >expect
.6030 <<-'EOF'
51 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
53 cat >expect2.60
<<-'EOF'
54 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
55 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
57 cat >expect2.6030
<<-'EOF'
58 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
59 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
61 while read expect cmd args
63 test_expect_success
"$cmd --stat=width: a long name is given more room when the bar is short" '
64 git $cmd $args --stat=40 >output &&
65 grep " | " output >actual &&
66 test_cmp $expect.60 actual
69 test_expect_success
"$cmd --stat-width=width with long name" '
70 git $cmd $args --stat-width=40 >output &&
71 grep " | " output >actual &&
72 test_cmp $expect.60 actual
75 test_expect_success
"$cmd --stat=...,name-width with long name" '
76 git $cmd $args --stat=60,30 >output &&
77 grep " | " output >actual &&
78 test_cmp $expect.6030 actual
81 test_expect_success
"$cmd --stat-name-width with long name" '
82 git $cmd $args --stat-name-width=30 >output &&
83 grep " | " output >actual &&
84 test_cmp $expect.6030 actual
87 expect2 format-patch
--cover-letter -1 --stdout
88 expect
diff HEAD^ HEAD
--stat
94 test_expect_success
'preparation for big change tests' '
97 git commit -m message &&
99 while test $i -lt 1000
101 echo $i && i=$(($i + 1))
103 git commit -m message abcd
106 cat >expect72
<<'EOF'
107 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110 test_expect_success
"format-patch --cover-letter ignores COLUMNS (big change)" '
111 COLUMNS=200 git format-patch -1 --stdout --cover-letter >output &&
112 grep " | " output >actual &&
113 test_cmp expect72 actual
116 cat >expect72
<<'EOF'
117 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119 cat >expect72-graph
<<'EOF'
120 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
122 cat >expect200
<<'EOF'
123 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
125 cat >expect200-graph
<<'EOF'
126 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
128 while read verb expect cmd args
130 test_expect_success
"$cmd $verb COLUMNS (big change)" '
131 COLUMNS=200 git $cmd $args >output &&
132 grep " | " output >actual &&
133 test_cmp "$expect" actual
136 case "$cmd" in diff|show
) continue;; esac
138 test_expect_success
"$cmd --graph $verb COLUMNS (big change)" '
139 COLUMNS=200 git $cmd $args --graph >output &&
140 grep " | " output >actual &&
141 test_cmp "$expect-graph" actual
144 ignores expect72 format-patch
-1 --stdout
145 respects expect200
diff HEAD^ HEAD
--stat
146 respects expect200 show
--stat
147 respects expect200 log
-1 --stat
150 cat >expect40
<<'EOF'
151 abcd | 1000 ++++++++++++++++++++++++++
153 cat >expect40-graph
<<'EOF'
154 | abcd | 1000 ++++++++++++++++++++++++
156 while read verb expect cmd args
158 test_expect_success
"$cmd $verb not enough COLUMNS (big change)" '
159 COLUMNS=40 git $cmd $args >output &&
160 grep " | " output >actual &&
161 test_cmp "$expect" actual
164 case "$cmd" in diff|show
) continue;; esac
166 test_expect_success
"$cmd --graph $verb not enough COLUMNS (big change)" '
167 COLUMNS=40 git $cmd $args --graph >output &&
168 grep " | " output >actual &&
169 test_cmp "$expect-graph" actual
172 ignores expect72 format-patch
-1 --stdout
173 respects expect40
diff HEAD^ HEAD
--stat
174 respects expect40 show
--stat
175 respects expect40 log
-1 --stat
178 cat >expect40
<<'EOF'
179 abcd | 1000 ++++++++++++++++++++++++++
181 cat >expect40-graph
<<'EOF'
182 | abcd | 1000 ++++++++++++++++++++++++++
184 while read verb expect cmd args
186 test_expect_success
"$cmd $verb statGraphWidth config" '
187 git -c diff.statGraphWidth=26 $cmd $args >output &&
188 grep " | " output >actual &&
189 test_cmp "$expect" actual
192 case "$cmd" in diff|show
) continue;; esac
194 test_expect_success
"$cmd --graph $verb statGraphWidth config" '
195 git -c diff.statGraphWidth=26 $cmd $args --graph >output &&
196 grep " | " output >actual &&
197 test_cmp "$expect-graph" actual
200 ignores expect72 format-patch
-1 --stdout
201 respects expect40
diff HEAD^ HEAD
--stat
202 respects expect40 show
--stat
203 respects expect40 log
-1 --stat
208 abcd | 1000 ++++++++++++++++++++++++++
210 cat >expect-graph
<<'EOF'
211 | abcd | 1000 ++++++++++++++++++++++++++
215 test_expect_success
"$cmd --stat=width with big change" '
216 git $cmd $args --stat=40 >output &&
217 grep " | " output >actual &&
218 test_cmp expect actual
221 test_expect_success
"$cmd --stat-width=width with big change" '
222 git $cmd $args --stat-width=40 >output &&
223 grep " | " output >actual &&
224 test_cmp expect actual
227 test_expect_success
"$cmd --stat-graph-width with big change" '
228 git $cmd $args --stat-graph-width=26 >output &&
229 grep " | " output >actual &&
230 test_cmp expect actual
233 case "$cmd" in diff|show
) continue;; esac
235 test_expect_success
"$cmd --stat-width=width --graph with big change" '
236 git $cmd $args --stat-width=40 --graph >output &&
237 grep " | " output >actual &&
238 test_cmp expect-graph actual
241 test_expect_success
"$cmd --stat-graph-width --graph with big change" '
242 git $cmd $args --stat-graph-width=26 --graph >output &&
243 grep " | " output >actual &&
244 test_cmp expect-graph actual
247 format-patch
-1 --stdout
248 diff HEAD^ HEAD
--stat
253 test_expect_success
'preparation for long filename tests' '
254 cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
255 git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
256 git commit -m message
260 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
262 cat >expect-graph
<<'EOF'
263 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
267 test_expect_success
"$cmd --stat=width with big change is more balanced" '
268 git $cmd $args --stat-width=60 >output &&
269 grep " | " output >actual &&
270 test_cmp expect actual
273 case "$cmd" in diff|show
) continue;; esac
275 test_expect_success
"$cmd --stat=width --graph with big change is balanced" '
276 git $cmd $args --stat-width=60 --graph >output &&
277 grep " | " output >actual &&
278 test_cmp expect-graph actual
281 format-patch
-1 --stdout
282 diff HEAD^ HEAD
--stat
287 cat >expect72
<<'EOF'
288 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++
290 cat >expect72-graph
<<'EOF'
291 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++
293 cat >expect200
<<'EOF'
294 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
296 cat >expect200-graph
<<'EOF'
297 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
299 while read verb expect cmd args
301 test_expect_success
"$cmd $verb COLUMNS (long filename)" '
302 COLUMNS=200 git $cmd $args >output &&
303 grep " | " output >actual &&
304 test_cmp "$expect" actual
307 case "$cmd" in diff|show
) continue;; esac
309 test_expect_success
"$cmd --graph $verb COLUMNS (long filename)" '
310 COLUMNS=200 git $cmd $args --graph >output &&
311 grep " | " output >actual &&
312 test_cmp "$expect-graph" actual
315 ignores expect72 format-patch
-1 --stdout
316 respects expect200
diff HEAD^ HEAD
--stat
317 respects expect200 show
--stat
318 respects expect200 log
-1 --stat
322 ...aaaaaaa | 1000 ++++++
324 cat >expect1-graph
<<'EOF'
325 | ...aaaaaaa | 1000 ++++++
327 while read verb expect cmd args
329 test_expect_success COLUMNS_CAN_BE_1 \
330 "$cmd $verb prefix greater than COLUMNS (big change)" '
331 COLUMNS=1 git $cmd $args >output &&
332 grep " | " output >actual &&
333 test_cmp "$expect" actual
336 case "$cmd" in diff|show
) continue;; esac
338 test_expect_success COLUMNS_CAN_BE_1 \
339 "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
340 COLUMNS=1 git $cmd $args --graph >output &&
341 grep " | " output >actual &&
342 test_cmp "$expect-graph" actual
345 ignores expect72 format-patch
-1 --stdout
346 respects expect1
diff HEAD^ HEAD
--stat
347 respects expect1 show
--stat
348 respects expect1 log
-1 --stat
352 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
354 test_expect_success
'merge --stat respects COLUMNS (big change)' '
355 git checkout -b branch HEAD^^ &&
356 COLUMNS=100 git merge --stat --no-ff master^ >output &&
357 grep " | " output >actual &&
358 test_cmp expect actual
362 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
364 test_expect_success
'merge --stat respects COLUMNS (long filename)' '
365 COLUMNS=100 git merge --stat --no-ff master >output &&
366 grep " | " output >actual &&
367 test_cmp expect actual