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"
25 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
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
34 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
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
49 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
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
63 format-patch
-1 --stdout
64 diff HEAD^ HEAD
--stat
70 test_expect_success
'preparation for big change tests' '
73 git commit -m message &&
75 while test $i -lt 1000
77 echo $i && i=$(($i + 1))
79 git commit -m message abcd
83 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
85 cat >expect80-graph
<<'EOF'
86 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
88 cat >expect200
<<'EOF'
89 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91 cat >expect200-graph
<<'EOF'
92 | abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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 case "$cmd" in diff|show
) continue;; esac
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
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 case "$cmd" in diff|show
) continue;; esac
132 test_expect_success
"$cmd --graph $verb not enough COLUMNS (big change)" '
133 COLUMNS=40 git $cmd $args --graph >output &&
134 grep " | " output >actual &&
135 test_cmp "$expect-graph" actual
138 ignores expect80 format-patch
-1 --stdout
139 respects expect40
diff HEAD^ HEAD
--stat
140 respects expect40 show
--stat
141 respects expect40 log
-1 --stat
144 cat >expect40
<<'EOF'
145 abcd | 1000 ++++++++++++++++++++++++++
147 cat >expect40-graph
<<'EOF'
148 | abcd | 1000 ++++++++++++++++++++++++++
150 while read verb expect cmd args
152 test_expect_success
"$cmd $verb statGraphWidth config" '
153 git -c diff.statGraphWidth=26 $cmd $args >output &&
154 grep " | " output >actual &&
155 test_cmp "$expect" actual
158 case "$cmd" in diff|show
) continue;; esac
160 test_expect_success
"$cmd --graph $verb statGraphWidth config" '
161 git -c diff.statGraphWidth=26 $cmd $args --graph >output &&
162 grep " | " output >actual &&
163 test_cmp "$expect-graph" actual
166 ignores expect80 format-patch
-1 --stdout
167 respects expect40
diff HEAD^ HEAD
--stat
168 respects expect40 show
--stat
169 respects expect40 log
-1 --stat
174 abcd | 1000 ++++++++++++++++++++++++++
176 cat >expect-graph
<<'EOF'
177 | abcd | 1000 ++++++++++++++++++++++++++
181 test_expect_success
"$cmd --stat=width with big change" '
182 git $cmd $args --stat=40 >output &&
183 grep " | " output >actual &&
184 test_cmp expect actual
187 test_expect_success
"$cmd --stat-width=width with big change" '
188 git $cmd $args --stat-width=40 >output &&
189 grep " | " output >actual &&
190 test_cmp expect actual
193 test_expect_success
"$cmd --stat-graph-width with big change" '
194 git $cmd $args --stat-graph-width=26 >output &&
195 grep " | " output >actual &&
196 test_cmp expect actual
199 case "$cmd" in diff|show
) continue;; esac
201 test_expect_success
"$cmd --stat-width=width --graph with big change" '
202 git $cmd $args --stat-width=40 --graph >output &&
203 grep " | " output >actual &&
204 test_cmp expect-graph actual
207 test_expect_success
"$cmd --stat-graph-width --graph with big change" '
208 git $cmd $args --stat-graph-width=26 --graph >output &&
209 grep " | " output >actual &&
210 test_cmp expect-graph actual
213 format-patch
-1 --stdout
214 diff HEAD^ HEAD
--stat
219 test_expect_success
'preparation for long filename tests' '
220 cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
221 git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
222 git commit -m message
226 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
228 cat >expect-graph
<<'EOF'
229 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
233 test_expect_success
"$cmd --stat=width with big change is more balanced" '
234 git $cmd $args --stat-width=60 >output &&
235 grep " | " output >actual &&
236 test_cmp expect actual
239 case "$cmd" in diff|show
) continue;; esac
241 test_expect_success
"$cmd --stat=width --graph with big change is balanced" '
242 git $cmd $args --stat-width=60 --graph >output &&
243 grep " | " output >actual &&
244 test_cmp expect-graph actual
247 format-patch
-1 --stdout
248 diff HEAD^ HEAD
--stat
253 cat >expect80
<<'EOF'
254 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
256 cat >expect80-graph
<<'EOF'
257 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
259 cat >expect200
<<'EOF'
260 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
262 cat >expect200-graph
<<'EOF'
263 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
265 while read verb expect cmd args
267 test_expect_success
"$cmd $verb COLUMNS (long filename)" '
268 COLUMNS=200 git $cmd $args >output &&
269 grep " | " output >actual &&
270 test_cmp "$expect" actual
273 case "$cmd" in diff|show
) continue;; esac
275 test_expect_success
"$cmd --graph $verb COLUMNS (long filename)" '
276 COLUMNS=200 git $cmd $args --graph >output &&
277 grep " | " output >actual &&
278 test_cmp "$expect-graph" actual
281 ignores expect80 format-patch
-1 --stdout
282 respects expect200
diff HEAD^ HEAD
--stat
283 respects expect200 show
--stat
284 respects expect200 log
-1 --stat
288 ...aaaaaaa | 1000 ++++++
290 cat >expect1-graph
<<'EOF'
291 | ...aaaaaaa | 1000 ++++++
293 while read verb expect cmd args
295 test_expect_success COLUMNS_CAN_BE_1 \
296 "$cmd $verb prefix greater than COLUMNS (big change)" '
297 COLUMNS=1 git $cmd $args >output &&
298 grep " | " output >actual &&
299 test_cmp "$expect" actual
302 case "$cmd" in diff|show
) continue;; esac
304 test_expect_success COLUMNS_CAN_BE_1 \
305 "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
306 COLUMNS=1 git $cmd $args --graph >output &&
307 grep " | " output >actual &&
308 test_cmp "$expect-graph" actual
311 ignores expect80 format-patch
-1 --stdout
312 respects expect1
diff HEAD^ HEAD
--stat
313 respects expect1 show
--stat
314 respects expect1 log
-1 --stat
318 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
320 test_expect_success
'merge --stat respects COLUMNS (big change)' '
321 git checkout -b branch HEAD^^ &&
322 COLUMNS=100 git merge --stat --no-ff master^ >output &&
323 grep " | " output >actual &&
324 test_cmp expect actual
328 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
330 test_expect_success
'merge --stat respects COLUMNS (long filename)' '
331 COLUMNS=100 git merge --stat --no-ff master >output &&
332 grep " | " output >actual &&
333 test_cmp expect actual