]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # Copyright (c) 2010, Will Palmer | |
4 | # Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests) | |
5 | # | |
6 | ||
7 | test_description='Test pretty formats' | |
8 | . ./test-lib.sh | |
9 | ||
10 | # Tested non-UTF-8 encoding | |
11 | test_encoding="ISO8859-1" | |
12 | ||
13 | sample_utf8_part=$(printf "f\303\244ng") | |
14 | ||
15 | commit_msg () { | |
16 | # String "initial. initial" partly in German | |
17 | # (translated with Google Translate), | |
18 | # encoded in UTF-8, used as a commit log message below. | |
19 | msg="initial. an${sample_utf8_part}lich\n" | |
20 | if test -n "$1" | |
21 | then | |
22 | printf "$msg" | iconv -f utf-8 -t "$1" | |
23 | else | |
24 | printf "$msg" | |
25 | fi | |
26 | } | |
27 | ||
28 | test_expect_success 'set up basic repos' ' | |
29 | >foo && | |
30 | >bar && | |
31 | git add foo && | |
32 | test_tick && | |
33 | test_config i18n.commitEncoding $test_encoding && | |
34 | commit_msg $test_encoding | git commit -F - && | |
35 | git add bar && | |
36 | test_tick && | |
37 | git commit -m "add bar" | |
38 | ' | |
39 | ||
40 | test_expect_success 'alias builtin format' ' | |
41 | git log --pretty=oneline >expected && | |
42 | test_config pretty.test-alias oneline && | |
43 | git log --pretty=test-alias >actual && | |
44 | test_cmp expected actual | |
45 | ' | |
46 | ||
47 | test_expect_success 'alias masking builtin format' ' | |
48 | git log --pretty=oneline >expected && | |
49 | test_config pretty.oneline "%H" && | |
50 | git log --pretty=oneline >actual && | |
51 | test_cmp expected actual | |
52 | ' | |
53 | ||
54 | test_expect_success 'alias user-defined format' ' | |
55 | git log --pretty="format:%h" >expected && | |
56 | test_config pretty.test-alias "format:%h" && | |
57 | git log --pretty=test-alias >actual && | |
58 | test_cmp expected actual | |
59 | ' | |
60 | ||
61 | test_expect_success 'alias user-defined format is matched case-insensitively' ' | |
62 | git log --pretty="format:%h" >expected && | |
63 | test_config pretty.testone "format:%h" && | |
64 | test_config pretty.testtwo testOne && | |
65 | git log --pretty=testTwo >actual && | |
66 | test_cmp expected actual | |
67 | ' | |
68 | ||
69 | test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' ' | |
70 | test_config i18n.logOutputEncoding $test_encoding && | |
71 | git log --oneline >expected-s && | |
72 | git log --pretty="tformat:%h %s" >actual-s && | |
73 | test_cmp expected-s actual-s | |
74 | ' | |
75 | ||
76 | test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' ' | |
77 | git log --oneline >expected-s && | |
78 | git log --pretty="tformat:%h %s" >actual-s && | |
79 | test_cmp expected-s actual-s | |
80 | ' | |
81 | ||
82 | test_expect_success 'alias user-defined tformat' ' | |
83 | git log --pretty="tformat:%h" >expected && | |
84 | test_config pretty.test-alias "tformat:%h" && | |
85 | git log --pretty=test-alias >actual && | |
86 | test_cmp expected actual | |
87 | ' | |
88 | ||
89 | test_expect_success 'alias non-existent format' ' | |
90 | test_config pretty.test-alias format-that-will-never-exist && | |
91 | test_must_fail git log --pretty=test-alias | |
92 | ' | |
93 | ||
94 | test_expect_success 'alias of an alias' ' | |
95 | git log --pretty="tformat:%h" >expected && | |
96 | test_config pretty.test-foo "tformat:%h" && | |
97 | test_config pretty.test-bar test-foo && | |
98 | git log --pretty=test-bar >actual && test_cmp expected actual | |
99 | ' | |
100 | ||
101 | test_expect_success 'alias masking an alias' ' | |
102 | git log --pretty=format:"Two %H" >expected && | |
103 | test_config pretty.duplicate "format:One %H" && | |
104 | test_config pretty.duplicate "format:Two %H" --add && | |
105 | git log --pretty=duplicate >actual && | |
106 | test_cmp expected actual | |
107 | ' | |
108 | ||
109 | test_expect_success 'alias loop' ' | |
110 | test_config pretty.test-foo test-bar && | |
111 | test_config pretty.test-bar test-foo && | |
112 | test_must_fail git log --pretty=test-foo | |
113 | ' | |
114 | ||
115 | test_expect_success 'NUL separation' ' | |
116 | printf "add bar\0$(commit_msg)" >expected && | |
117 | git log -z --pretty="format:%s" >actual && | |
118 | test_cmp expected actual | |
119 | ' | |
120 | ||
121 | test_expect_success 'NUL termination' ' | |
122 | printf "add bar\0$(commit_msg)\0" >expected && | |
123 | git log -z --pretty="tformat:%s" >actual && | |
124 | test_cmp expected actual | |
125 | ' | |
126 | ||
127 | test_expect_success 'NUL separation with --stat' ' | |
128 | stat0_part=$(git diff --stat HEAD^ HEAD) && | |
129 | stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && | |
130 | printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected && | |
131 | git log -z --stat --pretty="format:%s" >actual && | |
132 | test_cmp expected actual | |
133 | ' | |
134 | ||
135 | test_expect_failure 'NUL termination with --stat' ' | |
136 | stat0_part=$(git diff --stat HEAD^ HEAD) && | |
137 | stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) && | |
138 | printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected && | |
139 | git log -z --stat --pretty="tformat:%s" >actual && | |
140 | test_cmp expected actual | |
141 | ' | |
142 | ||
143 | for p in short medium full fuller email raw | |
144 | do | |
145 | test_expect_success "NUL termination with --reflog --pretty=$p" ' | |
146 | revs="$(git rev-list --reflog)" && | |
147 | for r in $revs | |
148 | do | |
149 | git show -s "$r" --pretty="$p" && | |
150 | printf "\0" || return 1 | |
151 | done >expect && | |
152 | { | |
153 | git log -z --reflog --pretty="$p" && | |
154 | printf "\0" | |
155 | } >actual && | |
156 | test_cmp expect actual | |
157 | ' | |
158 | done | |
159 | ||
160 | test_expect_success 'NUL termination with --reflog --pretty=oneline' ' | |
161 | revs="$(git rev-list --reflog)" && | |
162 | for r in $revs | |
163 | do | |
164 | git show -s --pretty=oneline "$r" >raw && | |
165 | cat raw | lf_to_nul || return 1 | |
166 | done >expect && | |
167 | # the trailing NUL is already produced so we do not need to | |
168 | # output another one | |
169 | git log -z --pretty=oneline --reflog >actual && | |
170 | test_cmp expect actual | |
171 | ' | |
172 | ||
173 | test_expect_success 'setup more commits' ' | |
174 | test_commit "message one" one one message-one && | |
175 | test_commit "message two" two two message-two && | |
176 | head1=$(git rev-parse --verify --short HEAD~0) && | |
177 | head2=$(git rev-parse --verify --short HEAD~1) && | |
178 | head3=$(git rev-parse --verify --short HEAD~2) && | |
179 | head4=$(git rev-parse --verify --short HEAD~3) | |
180 | ' | |
181 | ||
182 | test_expect_success 'left alignment formatting' ' | |
183 | git log --pretty="tformat:%<(40)%s" >actual && | |
184 | qz_to_tab_space <<-EOF >expected && | |
185 | message two Z | |
186 | message one Z | |
187 | add bar Z | |
188 | $(commit_msg) Z | |
189 | EOF | |
190 | test_cmp expected actual | |
191 | ' | |
192 | ||
193 | test_expect_success 'left alignment formatting. i18n.logOutputEncoding' ' | |
194 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual && | |
195 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
196 | message two Z | |
197 | message one Z | |
198 | add bar Z | |
199 | $(commit_msg) Z | |
200 | EOF | |
201 | test_cmp expected actual | |
202 | ' | |
203 | ||
204 | test_expect_success 'left alignment formatting at the nth column' ' | |
205 | git log --pretty="tformat:%h %<|(40)%s" >actual && | |
206 | qz_to_tab_space <<-EOF >expected && | |
207 | $head1 message two Z | |
208 | $head2 message one Z | |
209 | $head3 add bar Z | |
210 | $head4 $(commit_msg) Z | |
211 | EOF | |
212 | test_cmp expected actual | |
213 | ' | |
214 | ||
215 | test_expect_success 'left alignment formatting at the nth column' ' | |
216 | COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual && | |
217 | qz_to_tab_space <<-EOF >expected && | |
218 | $head1 message two Z | |
219 | $head2 message one Z | |
220 | $head3 add bar Z | |
221 | $head4 $(commit_msg) Z | |
222 | EOF | |
223 | test_cmp expected actual | |
224 | ' | |
225 | ||
226 | test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' ' | |
227 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual && | |
228 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
229 | $head1 message two Z | |
230 | $head2 message one Z | |
231 | $head3 add bar Z | |
232 | $head4 $(commit_msg) Z | |
233 | EOF | |
234 | test_cmp expected actual | |
235 | ' | |
236 | ||
237 | test_expect_success 'left alignment formatting with no padding' ' | |
238 | git log --pretty="tformat:%<(1)%s" >actual && | |
239 | cat <<-EOF >expected && | |
240 | message two | |
241 | message one | |
242 | add bar | |
243 | $(commit_msg) | |
244 | EOF | |
245 | test_cmp expected actual | |
246 | ' | |
247 | ||
248 | test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' ' | |
249 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual && | |
250 | cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
251 | message two | |
252 | message one | |
253 | add bar | |
254 | $(commit_msg) | |
255 | EOF | |
256 | test_cmp expected actual | |
257 | ' | |
258 | ||
259 | test_expect_success 'left alignment formatting with trunc' ' | |
260 | git log --pretty="tformat:%<(10,trunc)%s" >actual && | |
261 | qz_to_tab_space <<-\EOF >expected && | |
262 | message .. | |
263 | message .. | |
264 | add bar Z | |
265 | initial... | |
266 | EOF | |
267 | test_cmp expected actual | |
268 | ' | |
269 | ||
270 | test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncoding' ' | |
271 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual && | |
272 | qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected && | |
273 | message .. | |
274 | message .. | |
275 | add bar Z | |
276 | initial... | |
277 | EOF | |
278 | test_cmp expected actual | |
279 | ' | |
280 | ||
281 | test_expect_success 'left alignment formatting with ltrunc' ' | |
282 | git log --pretty="tformat:%<(10,ltrunc)%s" >actual && | |
283 | qz_to_tab_space <<-EOF >expected && | |
284 | ..sage two | |
285 | ..sage one | |
286 | add bar Z | |
287 | ..${sample_utf8_part}lich | |
288 | EOF | |
289 | test_cmp expected actual | |
290 | ' | |
291 | ||
292 | test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncoding' ' | |
293 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual && | |
294 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
295 | ..sage two | |
296 | ..sage one | |
297 | add bar Z | |
298 | ..${sample_utf8_part}lich | |
299 | EOF | |
300 | test_cmp expected actual | |
301 | ' | |
302 | ||
303 | test_expect_success 'left alignment formatting with mtrunc' ' | |
304 | git log --pretty="tformat:%<(10,mtrunc)%s" >actual && | |
305 | qz_to_tab_space <<-\EOF >expected && | |
306 | mess.. two | |
307 | mess.. one | |
308 | add bar Z | |
309 | init..lich | |
310 | EOF | |
311 | test_cmp expected actual | |
312 | ' | |
313 | ||
314 | test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncoding' ' | |
315 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual && | |
316 | qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected && | |
317 | mess.. two | |
318 | mess.. one | |
319 | add bar Z | |
320 | init..lich | |
321 | EOF | |
322 | test_cmp expected actual | |
323 | ' | |
324 | ||
325 | test_expect_success 'right alignment formatting' ' | |
326 | git log --pretty="tformat:%>(40)%s" >actual && | |
327 | qz_to_tab_space <<-EOF >expected && | |
328 | Z message two | |
329 | Z message one | |
330 | Z add bar | |
331 | Z $(commit_msg) | |
332 | EOF | |
333 | test_cmp expected actual | |
334 | ' | |
335 | ||
336 | test_expect_success 'right alignment formatting. i18n.logOutputEncoding' ' | |
337 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual && | |
338 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
339 | Z message two | |
340 | Z message one | |
341 | Z add bar | |
342 | Z $(commit_msg) | |
343 | EOF | |
344 | test_cmp expected actual | |
345 | ' | |
346 | ||
347 | test_expect_success 'right alignment formatting at the nth column' ' | |
348 | git log --pretty="tformat:%h %>|(40)%s" >actual && | |
349 | qz_to_tab_space <<-EOF >expected && | |
350 | $head1 message two | |
351 | $head2 message one | |
352 | $head3 add bar | |
353 | $head4 $(commit_msg) | |
354 | EOF | |
355 | test_cmp expected actual | |
356 | ' | |
357 | ||
358 | test_expect_success 'right alignment formatting at the nth column' ' | |
359 | COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual && | |
360 | qz_to_tab_space <<-EOF >expected && | |
361 | $head1 message two | |
362 | $head2 message one | |
363 | $head3 add bar | |
364 | $head4 $(commit_msg) | |
365 | EOF | |
366 | test_cmp expected actual | |
367 | ' | |
368 | ||
369 | test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' ' | |
370 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual && | |
371 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
372 | $head1 message two | |
373 | $head2 message one | |
374 | $head3 add bar | |
375 | $head4 $(commit_msg) | |
376 | EOF | |
377 | test_cmp expected actual | |
378 | ' | |
379 | ||
380 | # Note: Space between 'message' and 'two' should be in the same column | |
381 | # as in previous test. | |
382 | test_expect_success 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' ' | |
383 | git -c i18n.logOutputEncoding=$test_encoding log --graph --pretty="tformat:%h %>|(40)%s" >actual && | |
384 | iconv -f utf-8 -t $test_encoding >expected <<-EOF && | |
385 | * $head1 message two | |
386 | * $head2 message one | |
387 | * $head3 add bar | |
388 | * $head4 $(commit_msg) | |
389 | EOF | |
390 | test_cmp expected actual | |
391 | ' | |
392 | ||
393 | test_expect_success 'right alignment formatting with no padding' ' | |
394 | git log --pretty="tformat:%>(1)%s" >actual && | |
395 | cat <<-EOF >expected && | |
396 | message two | |
397 | message one | |
398 | add bar | |
399 | $(commit_msg) | |
400 | EOF | |
401 | test_cmp expected actual | |
402 | ' | |
403 | ||
404 | test_expect_success 'right alignment formatting with no padding and with --graph' ' | |
405 | git log --graph --pretty="tformat:%>(1)%s" >actual && | |
406 | cat <<-EOF >expected && | |
407 | * message two | |
408 | * message one | |
409 | * add bar | |
410 | * $(commit_msg) | |
411 | EOF | |
412 | test_cmp expected actual | |
413 | ' | |
414 | ||
415 | test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' ' | |
416 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual && | |
417 | cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
418 | message two | |
419 | message one | |
420 | add bar | |
421 | $(commit_msg) | |
422 | EOF | |
423 | test_cmp expected actual | |
424 | ' | |
425 | ||
426 | test_expect_success 'center alignment formatting' ' | |
427 | git log --pretty="tformat:%><(40)%s" >actual && | |
428 | qz_to_tab_space <<-EOF >expected && | |
429 | Z message two Z | |
430 | Z message one Z | |
431 | Z add bar Z | |
432 | Z $(commit_msg) Z | |
433 | EOF | |
434 | test_cmp expected actual | |
435 | ' | |
436 | ||
437 | test_expect_success 'center alignment formatting. i18n.logOutputEncoding' ' | |
438 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual && | |
439 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
440 | Z message two Z | |
441 | Z message one Z | |
442 | Z add bar Z | |
443 | Z $(commit_msg) Z | |
444 | EOF | |
445 | test_cmp expected actual | |
446 | ' | |
447 | test_expect_success 'center alignment formatting at the nth column' ' | |
448 | git log --pretty="tformat:%h %><|(40)%s" >actual && | |
449 | qz_to_tab_space <<-EOF >expected && | |
450 | $head1 message two Z | |
451 | $head2 message one Z | |
452 | $head3 add bar Z | |
453 | $head4 $(commit_msg) Z | |
454 | EOF | |
455 | test_cmp expected actual | |
456 | ' | |
457 | ||
458 | test_expect_success 'center alignment formatting at the nth column' ' | |
459 | COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual && | |
460 | qz_to_tab_space <<-EOF >expected && | |
461 | $head1 message two Z | |
462 | $head2 message one Z | |
463 | $head3 add bar Z | |
464 | $head4 $(commit_msg) Z | |
465 | EOF | |
466 | test_cmp expected actual | |
467 | ' | |
468 | ||
469 | test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' ' | |
470 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual && | |
471 | qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
472 | $head1 message two Z | |
473 | $head2 message one Z | |
474 | $head3 add bar Z | |
475 | $head4 $(commit_msg) Z | |
476 | EOF | |
477 | test_cmp expected actual | |
478 | ' | |
479 | ||
480 | test_expect_success 'center alignment formatting with no padding' ' | |
481 | git log --pretty="tformat:%><(1)%s" >actual && | |
482 | cat <<-EOF >expected && | |
483 | message two | |
484 | message one | |
485 | add bar | |
486 | $(commit_msg) | |
487 | EOF | |
488 | test_cmp expected actual | |
489 | ' | |
490 | ||
491 | # save HEAD's SHA-1 digest (with no abbreviations) to use it below | |
492 | # as far as the next test amends HEAD | |
493 | old_head1=$(git rev-parse --verify HEAD~0) | |
494 | test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' ' | |
495 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual && | |
496 | cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected && | |
497 | message two | |
498 | message one | |
499 | add bar | |
500 | $(commit_msg) | |
501 | EOF | |
502 | test_cmp expected actual | |
503 | ' | |
504 | ||
505 | test_expect_success 'left/right alignment formatting with stealing' ' | |
506 | git commit --amend -m short --author "long long long <long@me.com>" && | |
507 | git log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual && | |
508 | cat <<-\EOF >expected && | |
509 | short long long long | |
510 | message .. A U Thor | |
511 | add bar A U Thor | |
512 | initial... A U Thor | |
513 | EOF | |
514 | test_cmp expected actual | |
515 | ' | |
516 | test_expect_success 'left/right alignment formatting with stealing. i18n.logOutputEncoding' ' | |
517 | git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual && | |
518 | cat <<-\EOF | iconv -f utf-8 -t $test_encoding >expected && | |
519 | short long long long | |
520 | message .. A U Thor | |
521 | add bar A U Thor | |
522 | initial... A U Thor | |
523 | EOF | |
524 | test_cmp expected actual | |
525 | ' | |
526 | ||
527 | test_expect_success 'strbuf_utf8_replace() not producing NUL' ' | |
528 | git log --color --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)%C(auto)%d" | | |
529 | test_decode_color | | |
530 | nul_to_q >actual && | |
531 | ! grep Q actual | |
532 | ' | |
533 | ||
534 | # --date=[XXX] and corresponding %a[X] %c[X] format equivalency | |
535 | test_expect_success '--date=iso-strict %ad%cd is the same as %aI%cI' ' | |
536 | git log --format=%ad%n%cd --date=iso-strict >expected && | |
537 | git log --format=%aI%n%cI >actual && | |
538 | test_cmp expected actual | |
539 | ' | |
540 | ||
541 | test_expect_success '--date=short %ad%cd is the same as %as%cs' ' | |
542 | git log --format=%ad%n%cd --date=short >expected && | |
543 | git log --format=%as%n%cs >actual && | |
544 | test_cmp expected actual | |
545 | ' | |
546 | ||
547 | test_expect_success '--date=human %ad%cd is the same as %ah%ch' ' | |
548 | git log --format=%ad%n%cd --date=human >expected && | |
549 | git log --format=%ah%n%ch >actual && | |
550 | test_cmp expected actual | |
551 | ' | |
552 | ||
553 | # get new digests (with no abbreviations) | |
554 | test_expect_success 'set up log decoration tests' ' | |
555 | head1=$(git rev-parse --verify HEAD~0) && | |
556 | head2=$(git rev-parse --verify HEAD~1) | |
557 | ' | |
558 | ||
559 | test_expect_success 'log decoration properly follows tag chain' ' | |
560 | git tag -a tag1 -m tag1 && | |
561 | git tag -a tag2 -m tag2 tag1 && | |
562 | git tag -d tag1 && | |
563 | git commit --amend -m shorter && | |
564 | git log --no-walk --tags --pretty="%H %d" --decorate=full >actual && | |
565 | cat <<-EOF >expected && | |
566 | $head2 (tag: refs/tags/message-one) | |
567 | $old_head1 (tag: refs/tags/message-two) | |
568 | $head1 (tag: refs/tags/tag2) | |
569 | EOF | |
570 | sort -k3 actual >actual1 && | |
571 | test_cmp expected actual1 | |
572 | ' | |
573 | ||
574 | test_expect_success 'clean log decoration' ' | |
575 | git log --no-walk --tags --pretty="%H %D" --decorate=full >actual && | |
576 | cat >expected <<-EOF && | |
577 | $head2 tag: refs/tags/message-one | |
578 | $old_head1 tag: refs/tags/message-two | |
579 | $head1 tag: refs/tags/tag2 | |
580 | EOF | |
581 | sort -k3 actual >actual1 && | |
582 | test_cmp expected actual1 | |
583 | ' | |
584 | ||
585 | cat >trailers <<EOF | |
586 | Signed-off-by: A U Thor <author@example.com> | |
587 | Acked-by: A U Thor <author@example.com> | |
588 | [ v2 updated patch description ] | |
589 | Signed-off-by: A U Thor | |
590 | <author@example.com> | |
591 | EOF | |
592 | ||
593 | unfold () { | |
594 | perl -0pe 's/\n\s+/ /g' | |
595 | } | |
596 | ||
597 | test_expect_success 'set up trailer tests' ' | |
598 | echo "Some contents" >trailerfile && | |
599 | git add trailerfile && | |
600 | git commit -F - <<-EOF | |
601 | trailers: this commit message has trailers | |
602 | ||
603 | This commit is a test commit with trailers at the end. We parse this | |
604 | message and display the trailers using %(trailers). | |
605 | ||
606 | $(cat trailers) | |
607 | EOF | |
608 | ' | |
609 | ||
610 | test_expect_success 'pretty format %(trailers) shows trailers' ' | |
611 | git log --no-walk --pretty="%(trailers)" >actual && | |
612 | { | |
613 | cat trailers && | |
614 | echo | |
615 | } >expect && | |
616 | test_cmp expect actual | |
617 | ' | |
618 | ||
619 | test_expect_success 'pretty format %(trailers:) enables no options' ' | |
620 | git log --no-walk --pretty="%(trailers:)" >actual && | |
621 | # "expect" the same as the test above | |
622 | test_cmp expect actual | |
623 | ' | |
624 | ||
625 | test_expect_success '%(trailers:only) shows only "key: value" trailers' ' | |
626 | git log --no-walk --pretty="%(trailers:only)" >actual && | |
627 | { | |
628 | grep -v patch.description <trailers && | |
629 | echo | |
630 | } >expect && | |
631 | test_cmp expect actual | |
632 | ' | |
633 | ||
634 | test_expect_success '%(trailers:only=yes) shows only "key: value" trailers' ' | |
635 | git log --no-walk --pretty=format:"%(trailers:only=yes)" >actual && | |
636 | grep -v patch.description <trailers >expect && | |
637 | test_cmp expect actual | |
638 | ' | |
639 | ||
640 | test_expect_success '%(trailers:only=no) shows all trailers' ' | |
641 | git log --no-walk --pretty=format:"%(trailers:only=no)" >actual && | |
642 | cat trailers >expect && | |
643 | test_cmp expect actual | |
644 | ' | |
645 | ||
646 | test_expect_success '%(trailers:only=no,only=true) shows only "key: value" trailers' ' | |
647 | git log --no-walk --pretty=format:"%(trailers:only=yes)" >actual && | |
648 | grep -v patch.description <trailers >expect && | |
649 | test_cmp expect actual | |
650 | ' | |
651 | ||
652 | test_expect_success '%(trailers:unfold) unfolds trailers' ' | |
653 | git log --no-walk --pretty="%(trailers:unfold)" >actual && | |
654 | { | |
655 | unfold <trailers && | |
656 | echo | |
657 | } >expect && | |
658 | test_cmp expect actual | |
659 | ' | |
660 | ||
661 | test_expect_success ':only and :unfold work together' ' | |
662 | git log --no-walk --pretty="%(trailers:only,unfold)" >actual && | |
663 | git log --no-walk --pretty="%(trailers:unfold,only)" >reverse && | |
664 | test_cmp actual reverse && | |
665 | { | |
666 | grep -v patch.description <trailers | unfold && | |
667 | echo | |
668 | } >expect && | |
669 | test_cmp expect actual | |
670 | ' | |
671 | ||
672 | test_expect_success 'pretty format %(trailers:key=foo) shows that trailer' ' | |
673 | git log --no-walk --pretty="format:%(trailers:key=Acked-by)" >actual && | |
674 | echo "Acked-by: A U Thor <author@example.com>" >expect && | |
675 | test_cmp expect actual | |
676 | ' | |
677 | ||
678 | test_expect_success 'pretty format %(trailers:key=foo) is case insensitive' ' | |
679 | git log --no-walk --pretty="format:%(trailers:key=AcKed-bY)" >actual && | |
680 | echo "Acked-by: A U Thor <author@example.com>" >expect && | |
681 | test_cmp expect actual | |
682 | ' | |
683 | ||
684 | test_expect_success 'pretty format %(trailers:key=foo:) trailing colon also works' ' | |
685 | git log --no-walk --pretty="format:%(trailers:key=Acked-by:)" >actual && | |
686 | echo "Acked-by: A U Thor <author@example.com>" >expect && | |
687 | test_cmp expect actual | |
688 | ' | |
689 | ||
690 | test_expect_success 'pretty format %(trailers:key=foo) multiple keys' ' | |
691 | git log --no-walk --pretty="format:%(trailers:key=Acked-by:,key=Signed-off-By)" >actual && | |
692 | grep -v patch.description <trailers >expect && | |
693 | test_cmp expect actual | |
694 | ' | |
695 | ||
696 | test_expect_success '%(trailers:key=nonexistent) becomes empty' ' | |
697 | git log --no-walk --pretty="x%(trailers:key=Nacked-by)x" >actual && | |
698 | echo "xx" >expect && | |
699 | test_cmp expect actual | |
700 | ' | |
701 | ||
702 | test_expect_success '%(trailers:key=foo) handles multiple lines even if folded' ' | |
703 | git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by)" >actual && | |
704 | grep -v patch.description <trailers | grep -v Acked-by >expect && | |
705 | test_cmp expect actual | |
706 | ' | |
707 | ||
708 | test_expect_success '%(trailers:key=foo,unfold) properly unfolds' ' | |
709 | git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by,unfold)" >actual && | |
710 | unfold <trailers | grep Signed-off-by >expect && | |
711 | test_cmp expect actual | |
712 | ' | |
713 | ||
714 | test_expect_success 'pretty format %(trailers:key=foo,only=no) also includes nontrailer lines' ' | |
715 | git log --no-walk --pretty="format:%(trailers:key=Acked-by,only=no)" >actual && | |
716 | { | |
717 | echo "Acked-by: A U Thor <author@example.com>" && | |
718 | grep patch.description <trailers | |
719 | } >expect && | |
720 | test_cmp expect actual | |
721 | ' | |
722 | ||
723 | test_expect_success '%(trailers:key) without value is error' ' | |
724 | git log --no-walk --pretty="tformat:%(trailers:key)" >actual && | |
725 | echo "%(trailers:key)" >expect && | |
726 | test_cmp expect actual | |
727 | ' | |
728 | ||
729 | test_expect_success '%(trailers:keyonly) shows only keys' ' | |
730 | git log --no-walk --pretty="format:%(trailers:keyonly)" >actual && | |
731 | test_write_lines \ | |
732 | "Signed-off-by" \ | |
733 | "Acked-by" \ | |
734 | "[ v2 updated patch description ]" \ | |
735 | "Signed-off-by" >expect && | |
736 | test_cmp expect actual | |
737 | ' | |
738 | ||
739 | test_expect_success '%(trailers:key=foo,keyonly) shows only key' ' | |
740 | git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly)" >actual && | |
741 | echo "Acked-by" >expect && | |
742 | test_cmp expect actual | |
743 | ' | |
744 | ||
745 | test_expect_success '%(trailers:key=foo,valueonly) shows only value' ' | |
746 | git log --no-walk --pretty="format:%(trailers:key=Acked-by,valueonly)" >actual && | |
747 | echo "A U Thor <author@example.com>" >expect && | |
748 | test_cmp expect actual | |
749 | ' | |
750 | ||
751 | test_expect_success '%(trailers:valueonly) shows only values' ' | |
752 | git log --no-walk --pretty="format:%(trailers:valueonly)" >actual && | |
753 | test_write_lines \ | |
754 | "A U Thor <author@example.com>" \ | |
755 | "A U Thor <author@example.com>" \ | |
756 | "[ v2 updated patch description ]" \ | |
757 | "A U Thor" \ | |
758 | " <author@example.com>" >expect && | |
759 | test_cmp expect actual | |
760 | ' | |
761 | ||
762 | test_expect_success '%(trailers:key=foo,keyonly,valueonly) shows nothing' ' | |
763 | git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly,valueonly)" >actual && | |
764 | echo >expect && | |
765 | test_cmp expect actual | |
766 | ' | |
767 | ||
768 | test_expect_success 'pretty format %(trailers:separator) changes separator' ' | |
769 | git log --no-walk --pretty=format:"X%(trailers:separator=%x00)X" >actual && | |
770 | ( | |
771 | printf "XSigned-off-by: A U Thor <author@example.com>\0" && | |
772 | printf "Acked-by: A U Thor <author@example.com>\0" && | |
773 | printf "[ v2 updated patch description ]\0" && | |
774 | printf "Signed-off-by: A U Thor\n <author@example.com>X" | |
775 | ) >expect && | |
776 | test_cmp expect actual | |
777 | ' | |
778 | ||
779 | test_expect_success 'pretty format %(trailers:separator=X,unfold) changes separator' ' | |
780 | git log --no-walk --pretty=format:"X%(trailers:separator=%x00,unfold)X" >actual && | |
781 | ( | |
782 | printf "XSigned-off-by: A U Thor <author@example.com>\0" && | |
783 | printf "Acked-by: A U Thor <author@example.com>\0" && | |
784 | printf "[ v2 updated patch description ]\0" && | |
785 | printf "Signed-off-by: A U Thor <author@example.com>X" | |
786 | ) >expect && | |
787 | test_cmp expect actual | |
788 | ' | |
789 | ||
790 | test_expect_success 'pretty format %(trailers:key_value_separator) changes key-value separator' ' | |
791 | git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00)X" >actual && | |
792 | ( | |
793 | printf "XSigned-off-by\0A U Thor <author@example.com>\n" && | |
794 | printf "Acked-by\0A U Thor <author@example.com>\n" && | |
795 | printf "[ v2 updated patch description ]\n" && | |
796 | printf "Signed-off-by\0A U Thor\n <author@example.com>\nX" | |
797 | ) >expect && | |
798 | test_cmp expect actual | |
799 | ' | |
800 | ||
801 | test_expect_success 'pretty format %(trailers:key_value_separator,unfold) changes key-value separator' ' | |
802 | git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00,unfold)X" >actual && | |
803 | ( | |
804 | printf "XSigned-off-by\0A U Thor <author@example.com>\n" && | |
805 | printf "Acked-by\0A U Thor <author@example.com>\n" && | |
806 | printf "[ v2 updated patch description ]\n" && | |
807 | printf "Signed-off-by\0A U Thor <author@example.com>\nX" | |
808 | ) >expect && | |
809 | test_cmp expect actual | |
810 | ' | |
811 | ||
812 | test_expect_success 'pretty format %(trailers:separator,key_value_separator) changes both separators' ' | |
813 | git log --no-walk --pretty=format:"%(trailers:separator=%x00,key_value_separator=%x00%x00,unfold)" >actual && | |
814 | ( | |
815 | printf "Signed-off-by\0\0A U Thor <author@example.com>\0" && | |
816 | printf "Acked-by\0\0A U Thor <author@example.com>\0" && | |
817 | printf "[ v2 updated patch description ]\0" && | |
818 | printf "Signed-off-by\0\0A U Thor <author@example.com>" | |
819 | ) >expect && | |
820 | test_cmp expect actual | |
821 | ' | |
822 | ||
823 | test_expect_success 'pretty format %(trailers) combining separator/key/keyonly/valueonly' ' | |
824 | git commit --allow-empty -F - <<-\EOF && | |
825 | Important fix | |
826 | ||
827 | The fix is explained here | |
828 | ||
829 | Closes: #1234 | |
830 | EOF | |
831 | ||
832 | git commit --allow-empty -F - <<-\EOF && | |
833 | Another fix | |
834 | ||
835 | The fix is explained here | |
836 | ||
837 | Closes: #567 | |
838 | Closes: #890 | |
839 | EOF | |
840 | ||
841 | git commit --allow-empty -F - <<-\EOF && | |
842 | Does not close any tickets | |
843 | EOF | |
844 | ||
845 | git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,valueonly)" HEAD~3.. >actual && | |
846 | test_write_lines \ | |
847 | "Does not close any tickets" \ | |
848 | "Another fix #567, #890" \ | |
849 | "Important fix #1234" >expect && | |
850 | test_cmp expect actual && | |
851 | ||
852 | git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,keyonly)" HEAD~3.. >actual && | |
853 | test_write_lines \ | |
854 | "Does not close any tickets" \ | |
855 | "Another fix Closes, Closes" \ | |
856 | "Important fix Closes" >expect && | |
857 | test_cmp expect actual | |
858 | ' | |
859 | ||
860 | test_expect_success 'trailer parsing not fooled by --- line' ' | |
861 | git commit --allow-empty -F - <<-\EOF && | |
862 | this is the subject | |
863 | ||
864 | This is the body. The message has a "---" line which would confuse a | |
865 | message+patch parser. But here we know we have only a commit message, | |
866 | so we get it right. | |
867 | ||
868 | trailer: wrong | |
869 | --- | |
870 | This is more body. | |
871 | ||
872 | trailer: right | |
873 | EOF | |
874 | ||
875 | { | |
876 | echo "trailer: right" && | |
877 | echo | |
878 | } >expect && | |
879 | git log --no-walk --format="%(trailers)" >actual && | |
880 | test_cmp expect actual | |
881 | ' | |
882 | ||
883 | test_expect_success 'set up %S tests' ' | |
884 | git checkout --orphan source-a && | |
885 | test_commit one && | |
886 | test_commit two && | |
887 | git checkout -b source-b HEAD^ && | |
888 | test_commit three | |
889 | ' | |
890 | ||
891 | test_expect_success 'log --format=%S paints branch names' ' | |
892 | cat >expect <<-\EOF && | |
893 | source-b | |
894 | source-a | |
895 | source-b | |
896 | EOF | |
897 | git log --format=%S source-a source-b >actual && | |
898 | test_cmp expect actual | |
899 | ' | |
900 | ||
901 | test_expect_success 'log --format=%S paints tag names' ' | |
902 | git tag -m tagged source-tag && | |
903 | cat >expect <<-\EOF && | |
904 | source-tag | |
905 | source-a | |
906 | source-tag | |
907 | EOF | |
908 | git log --format=%S source-tag source-a >actual && | |
909 | test_cmp expect actual | |
910 | ' | |
911 | ||
912 | test_expect_success 'log --format=%S paints symmetric ranges' ' | |
913 | cat >expect <<-\EOF && | |
914 | source-b | |
915 | source-a | |
916 | EOF | |
917 | git log --format=%S source-a...source-b >actual && | |
918 | test_cmp expect actual | |
919 | ' | |
920 | ||
921 | test_expect_success '%S in git log --format works with other placeholders (part 1)' ' | |
922 | git log --format="source-b %h" source-b >expect && | |
923 | git log --format="%S %h" source-b >actual && | |
924 | test_cmp expect actual | |
925 | ' | |
926 | ||
927 | test_expect_success '%S in git log --format works with other placeholders (part 2)' ' | |
928 | git log --format="%h source-b" source-b >expect && | |
929 | git log --format="%h %S" source-b >actual && | |
930 | test_cmp expect actual | |
931 | ' | |
932 | ||
933 | test_expect_success 'log --pretty=reference' ' | |
934 | git log --pretty="tformat:%h (%s, %as)" >expect && | |
935 | git log --pretty=reference >actual && | |
936 | test_cmp expect actual | |
937 | ' | |
938 | ||
939 | test_expect_success 'log --pretty=reference with log.date is overridden by short date' ' | |
940 | git log --pretty="tformat:%h (%s, %as)" >expect && | |
941 | test_config log.date rfc && | |
942 | git log --pretty=reference >actual && | |
943 | test_cmp expect actual | |
944 | ' | |
945 | ||
946 | test_expect_success 'log --pretty=reference with explicit date overrides short date' ' | |
947 | git log --date=rfc --pretty="tformat:%h (%s, %ad)" >expect && | |
948 | git log --date=rfc --pretty=reference >actual && | |
949 | test_cmp expect actual | |
950 | ' | |
951 | ||
952 | test_expect_success 'log --pretty=reference is never unabbreviated' ' | |
953 | git log --pretty="tformat:%h (%s, %as)" >expect && | |
954 | git log --no-abbrev-commit --pretty=reference >actual && | |
955 | test_cmp expect actual | |
956 | ' | |
957 | ||
958 | test_expect_success 'log --pretty=reference is never decorated' ' | |
959 | git log --pretty="tformat:%h (%s, %as)" >expect && | |
960 | git log --decorate=short --pretty=reference >actual && | |
961 | test_cmp expect actual | |
962 | ' | |
963 | ||
964 | test_expect_success 'log --pretty=reference does not output reflog info' ' | |
965 | git log --walk-reflogs --pretty="tformat:%h (%s, %as)" >expect && | |
966 | git log --walk-reflogs --pretty=reference >actual && | |
967 | test_cmp expect actual | |
968 | ' | |
969 | ||
970 | test_expect_success 'log --pretty=reference is colored appropriately' ' | |
971 | git log --color=always --pretty="tformat:%C(auto)%h (%s, %as)" >expect && | |
972 | git log --color=always --pretty=reference >actual && | |
973 | test_cmp expect actual | |
974 | ' | |
975 | ||
976 | test_expect_success '%(describe) vs git describe' ' | |
977 | git log --format="%H" | while read hash | |
978 | do | |
979 | if desc=$(git describe $hash) | |
980 | then | |
981 | : >expect-contains-good | |
982 | else | |
983 | : >expect-contains-bad | |
984 | fi && | |
985 | echo "$hash $desc" || return 1 | |
986 | done >expect && | |
987 | test_path_exists expect-contains-good && | |
988 | test_path_exists expect-contains-bad && | |
989 | ||
990 | git log --format="%H %(describe)" >actual 2>err && | |
991 | test_cmp expect actual && | |
992 | test_must_be_empty err | |
993 | ' | |
994 | ||
995 | test_expect_success '%(describe:match=...) vs git describe --match ...' ' | |
996 | test_when_finished "git tag -d tag-match" && | |
997 | git tag -a -m tagged tag-match && | |
998 | git describe --match "*-match" >expect && | |
999 | git log -1 --format="%(describe:match=*-match)" >actual && | |
1000 | test_cmp expect actual | |
1001 | ' | |
1002 | ||
1003 | test_expect_success '%(describe:exclude=...) vs git describe --exclude ...' ' | |
1004 | test_when_finished "git tag -d tag-exclude" && | |
1005 | git tag -a -m tagged tag-exclude && | |
1006 | git describe --exclude "*-exclude" >expect && | |
1007 | git log -1 --format="%(describe:exclude=*-exclude)" >actual && | |
1008 | test_cmp expect actual | |
1009 | ' | |
1010 | ||
1011 | test_expect_success '%(describe:tags) vs git describe --tags' ' | |
1012 | test_when_finished "git tag -d tagname" && | |
1013 | git tag tagname && | |
1014 | git describe --tags >expect && | |
1015 | git log -1 --format="%(describe:tags)" >actual && | |
1016 | test_cmp expect actual | |
1017 | ' | |
1018 | ||
1019 | test_expect_success '%(describe:abbrev=...) vs git describe --abbrev=...' ' | |
1020 | test_when_finished "git tag -d tagname" && | |
1021 | git tag -a -m tagged tagname && | |
1022 | git describe --abbrev=15 >expect && | |
1023 | git log -1 --format="%(describe:abbrev=15)" >actual && | |
1024 | test_cmp expect actual | |
1025 | ' | |
1026 | ||
1027 | test_expect_success 'log --pretty with space stealing' ' | |
1028 | printf mm0 >expect && | |
1029 | git log -1 --pretty="format:mm%>>|(1)%x30" >actual && | |
1030 | test_cmp expect actual | |
1031 | ' | |
1032 | ||
1033 | test_expect_success 'log --pretty with invalid padding format' ' | |
1034 | printf "%s%%<(20" "$(git rev-parse HEAD)" >expect && | |
1035 | git log -1 --pretty="format:%H%<(20" >actual && | |
1036 | test_cmp expect actual | |
1037 | ' | |
1038 | ||
1039 | test_expect_success 'log --pretty with magical wrapping directives' ' | |
1040 | commit_id=$(git commit-tree HEAD^{tree} -m "describe me") && | |
1041 | git tag describe-me $commit_id && | |
1042 | printf "\n(tag:\ndescribe-me)%%+w(2)" >expect && | |
1043 | git log -1 --pretty="format:%w(1)%+d%+w(2)" $commit_id >actual && | |
1044 | test_cmp expect actual | |
1045 | ' | |
1046 | ||
1047 | test_expect_success SIZE_T_IS_64BIT 'log --pretty with overflowing wrapping directive' ' | |
1048 | printf "%%w(2147483649,1,1)0" >expect && | |
1049 | git log -1 --pretty="format:%w(2147483649,1,1)%x30" >actual && | |
1050 | test_cmp expect actual && | |
1051 | printf "%%w(1,2147483649,1)0" >expect && | |
1052 | git log -1 --pretty="format:%w(1,2147483649,1)%x30" >actual && | |
1053 | test_cmp expect actual && | |
1054 | printf "%%w(1,1,2147483649)0" >expect && | |
1055 | git log -1 --pretty="format:%w(1,1,2147483649)%x30" >actual && | |
1056 | test_cmp expect actual | |
1057 | ' | |
1058 | ||
1059 | test_expect_success SIZE_T_IS_64BIT 'log --pretty with overflowing padding directive' ' | |
1060 | printf "%%<(2147483649)0" >expect && | |
1061 | git log -1 --pretty="format:%<(2147483649)%x30" >actual && | |
1062 | test_cmp expect actual | |
1063 | ' | |
1064 | ||
1065 | test_expect_success 'log --pretty with padding and preceding control chars' ' | |
1066 | printf "\20\20 0" >expect && | |
1067 | git log -1 --pretty="format:%x10%x10%>|(4)%x30" >actual && | |
1068 | test_cmp expect actual | |
1069 | ' | |
1070 | ||
1071 | test_expect_success 'log --pretty truncation with control chars' ' | |
1072 | test_commit "$(printf "\20\20\20\20xxxx")" file contents commit-with-control-chars && | |
1073 | printf "\20\20\20\20x.." >expect && | |
1074 | git log -1 --pretty="format:%<(3,trunc)%s" commit-with-control-chars >actual && | |
1075 | test_cmp expect actual | |
1076 | ' | |
1077 | ||
1078 | test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' ' | |
1079 | # We only assert that this command does not crash. This needs to be | |
1080 | # executed with the address sanitizer to demonstrate failure. | |
1081 | git log -1 --pretty="format:%>(2147483646)%x41%41%>(2147483646)%x41" >/dev/null | |
1082 | ' | |
1083 | ||
1084 | test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'set up huge commit' ' | |
1085 | test-tool genzeros 2147483649 | tr "\000" "1" >expect && | |
1086 | huge_commit=$(git commit-tree -F expect HEAD^{tree}) | |
1087 | ' | |
1088 | ||
1089 | test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message' ' | |
1090 | git log -1 --format="%B%<(1)%x30" $huge_commit >actual && | |
1091 | echo 0 >>expect && | |
1092 | test_cmp expect actual | |
1093 | ' | |
1094 | ||
1095 | test_expect_success EXPENSIVE,SIZE_T_IS_64BIT 'log --pretty with huge commit message does not cause allocation failure' ' | |
1096 | test_must_fail git log -1 --format="%<(1)%B" $huge_commit 2>error && | |
1097 | cat >expect <<-EOF && | |
1098 | fatal: number too large to represent as int on this platform: 2147483649 | |
1099 | EOF | |
1100 | test_cmp expect error | |
1101 | ' | |
1102 | ||
1103 | # pretty-formats note wide char limitations, and add tests | |
1104 | test_expect_failure 'wide and decomposed characters column counting' ' | |
1105 | ||
1106 | # from t/lib-unicode-nfc-nfd.sh hex values converted to octal | |
1107 | utf8_nfc=$(printf "\303\251") && # e acute combined. | |
1108 | utf8_nfd=$(printf "\145\314\201") && # e with a combining acute (i.e. decomposed) | |
1109 | utf8_emoji=$(printf "\360\237\221\250") && | |
1110 | ||
1111 | # replacement character when requesting a wide char fits in a single display colum. | |
1112 | # "half wide" alternative could be a plain ASCII dot `.` | |
1113 | utf8_vert_ell=$(printf "\342\213\256") && | |
1114 | ||
1115 | # use ${xxx} here! | |
1116 | nfc10="${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}${utf8_nfc}" && | |
1117 | nfd10="${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}${utf8_nfd}" && | |
1118 | emoji5="${utf8_emoji}${utf8_emoji}${utf8_emoji}${utf8_emoji}${utf8_emoji}" && | |
1119 | # emoji5 uses 10 display columns | |
1120 | ||
1121 | test_commit "abcdefghij" && | |
1122 | test_commit --no-tag "${nfc10}" && | |
1123 | test_commit --no-tag "${nfd10}" && | |
1124 | test_commit --no-tag "${emoji5}" && | |
1125 | printf "${utf8_emoji}..${utf8_emoji}${utf8_vert_ell}\n${utf8_nfd}..${utf8_nfd}${utf8_nfd}\n${utf8_nfc}..${utf8_nfc}${utf8_nfc}\na..ij\n" >expected && | |
1126 | git log --format="%<(5,mtrunc)%s" -4 >actual && | |
1127 | test_cmp expected actual | |
1128 | ' | |
1129 | ||
1130 | test_done |