3 # Copyright (c) 2010, Will Palmer
4 # Copyright (c) 2011, Alexey Shumkin (+ non-UTF-8 commit encoding tests)
7 test_description='Test pretty formats'
10 # Tested non-UTF-8 encoding
11 test_encoding="ISO8859-1"
13 sample_utf8_part=$(printf "f\303\244ng")
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"
22 printf "$msg" | iconv -f utf-8 -t "$1"
28 test_expect_success 'set up basic repos' '
33 git config i18n.commitEncoding $test_encoding &&
34 commit_msg $test_encoding | git commit -F - &&
37 git commit -m "add bar" &&
38 git config --unset i18n.commitEncoding
41 test_expect_success 'alias builtin format' '
42 git log --pretty=oneline >expected &&
43 git config pretty.test-alias oneline &&
44 git log --pretty=test-alias >actual &&
45 test_cmp expected actual
48 test_expect_success 'alias masking builtin format' '
49 git log --pretty=oneline >expected &&
50 git config pretty.oneline "%H" &&
51 git log --pretty=oneline >actual &&
52 test_cmp expected actual
55 test_expect_success 'alias user-defined format' '
56 git log --pretty="format:%h" >expected &&
57 git config pretty.test-alias "format:%h" &&
58 git log --pretty=test-alias >actual &&
59 test_cmp expected actual
62 test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
63 git config i18n.logOutputEncoding $test_encoding &&
64 git log --oneline >expected-s &&
65 git log --pretty="tformat:%h %s" >actual-s &&
66 git config --unset i18n.logOutputEncoding &&
67 test_cmp expected-s actual-s
70 test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
71 git log --oneline >expected-s &&
72 git log --pretty="tformat:%h %s" >actual-s &&
73 test_cmp expected-s actual-s
76 test_expect_success 'alias user-defined tformat' '
77 git log --pretty="tformat:%h" >expected &&
78 git config pretty.test-alias "tformat:%h" &&
79 git log --pretty=test-alias >actual &&
80 test_cmp expected actual
83 test_expect_success 'alias non-existent format' '
84 git config pretty.test-alias format-that-will-never-exist &&
85 test_must_fail git log --pretty=test-alias
88 test_expect_success 'alias of an alias' '
89 git log --pretty="tformat:%h" >expected &&
90 git config pretty.test-foo "tformat:%h" &&
91 git config pretty.test-bar test-foo &&
92 git log --pretty=test-bar >actual && test_cmp expected actual
95 test_expect_success 'alias masking an alias' '
96 git log --pretty=format:"Two %H" >expected &&
97 git config pretty.duplicate "format:One %H" &&
98 git config --add pretty.duplicate "format:Two %H" &&
99 git log --pretty=duplicate >actual &&
100 test_cmp expected actual
103 test_expect_success 'alias loop' '
104 git config pretty.test-foo test-bar &&
105 git config pretty.test-bar test-foo &&
106 test_must_fail git log --pretty=test-foo
109 test_expect_success 'NUL separation' '
110 printf "add bar\0$(commit_msg)" >expected &&
111 git log -z --pretty="format:%s" >actual &&
112 test_cmp expected actual
115 test_expect_success 'NUL termination' '
116 printf "add bar\0$(commit_msg)\0" >expected &&
117 git log -z --pretty="tformat:%s" >actual &&
118 test_cmp expected actual
121 test_expect_success 'NUL separation with --stat' '
122 stat0_part=$(git diff --stat HEAD^ HEAD) &&
123 stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
124 printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
125 git log -z --stat --pretty="format:%s" >actual &&
126 test_i18ncmp expected actual
129 test_expect_failure C_LOCALE_OUTPUT 'NUL termination with --stat' '
130 stat0_part=$(git diff --stat HEAD^ HEAD) &&
131 stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
132 printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n0" >expected &&
133 git log -z --stat --pretty="tformat:%s" >actual &&
134 test_cmp expected actual
137 for p in short medium full fuller email raw
139 test_expect_success "NUL termination with --reflog --pretty=$p" '
140 revs="$(git rev-list --reflog)" &&
143 git show -s "$r" --pretty="$p" &&
144 printf "\0" || return 1
147 git log -z --reflog --pretty="$p" &&
150 test_cmp expect actual
154 test_expect_success 'NUL termination with --reflog --pretty=oneline' '
155 revs="$(git rev-list --reflog)" &&
158 git show -s --pretty=oneline "$r" >raw &&
159 cat raw | lf_to_nul || exit 1
161 # the trailing NUL is already produced so we do not need to
163 git log -z --pretty=oneline --reflog >actual &&
164 test_cmp expect actual
167 test_expect_success 'setup more commits' '
168 test_commit "message one" one one message-one &&
169 test_commit "message two" two two message-two &&
170 head1=$(git rev-parse --verify --short HEAD~0) &&
171 head2=$(git rev-parse --verify --short HEAD~1) &&
172 head3=$(git rev-parse --verify --short HEAD~2) &&
173 head4=$(git rev-parse --verify --short HEAD~3)
176 test_expect_success 'left alignment formatting' '
177 git log --pretty="tformat:%<(40)%s" >actual &&
178 qz_to_tab_space <<-EOF >expected &&
184 test_cmp expected actual
187 test_expect_success 'left alignment formatting. i18n.logOutputEncoding' '
188 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(40)%s" >actual &&
189 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
195 test_cmp expected actual
198 test_expect_success 'left alignment formatting at the nth column' '
199 git log --pretty="tformat:%h %<|(40)%s" >actual &&
200 qz_to_tab_space <<-EOF >expected &&
204 $head4 $(commit_msg) Z
206 test_cmp expected actual
209 test_expect_success 'left alignment formatting at the nth column' '
210 COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
211 qz_to_tab_space <<-EOF >expected &&
215 $head4 $(commit_msg) Z
217 test_cmp expected actual
220 test_expect_success 'left alignment formatting at the nth column. i18n.logOutputEncoding' '
221 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %<|(40)%s" >actual &&
222 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
226 $head4 $(commit_msg) Z
228 test_cmp expected actual
231 test_expect_success 'left alignment formatting with no padding' '
232 git log --pretty="tformat:%<(1)%s" >actual &&
233 cat <<-EOF >expected &&
239 test_cmp expected actual
242 test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
243 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
244 cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
250 test_cmp expected actual
253 test_expect_success 'left alignment formatting with trunc' '
254 git log --pretty="tformat:%<(10,trunc)%s" >actual &&
255 qz_to_tab_space <<-\EOF >expected &&
261 test_cmp expected actual
264 test_expect_success 'left alignment formatting with trunc. i18n.logOutputEncoding' '
265 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s" >actual &&
266 qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
272 test_cmp expected actual
275 test_expect_success 'left alignment formatting with ltrunc' '
276 git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
277 qz_to_tab_space <<-EOF >expected &&
281 ..${sample_utf8_part}lich
283 test_cmp expected actual
286 test_expect_success 'left alignment formatting with ltrunc. i18n.logOutputEncoding' '
287 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
288 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
292 ..${sample_utf8_part}lich
294 test_cmp expected actual
297 test_expect_success 'left alignment formatting with mtrunc' '
298 git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
299 qz_to_tab_space <<-\EOF >expected &&
305 test_cmp expected actual
308 test_expect_success 'left alignment formatting with mtrunc. i18n.logOutputEncoding' '
309 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
310 qz_to_tab_space <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
316 test_cmp expected actual
319 test_expect_success 'right alignment formatting' '
320 git log --pretty="tformat:%>(40)%s" >actual &&
321 qz_to_tab_space <<-EOF >expected &&
327 test_cmp expected actual
330 test_expect_success 'right alignment formatting. i18n.logOutputEncoding' '
331 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(40)%s" >actual &&
332 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
338 test_cmp expected actual
341 test_expect_success 'right alignment formatting at the nth column' '
342 git log --pretty="tformat:%h %>|(40)%s" >actual &&
343 qz_to_tab_space <<-EOF >expected &&
349 test_cmp expected actual
352 test_expect_success 'right alignment formatting at the nth column' '
353 COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
354 qz_to_tab_space <<-EOF >expected &&
360 test_cmp expected actual
363 test_expect_success 'right alignment formatting at the nth column. i18n.logOutputEncoding' '
364 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %>|(40)%s" >actual &&
365 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
371 test_cmp expected actual
374 # Note: Space between 'message' and 'two' should be in the same column
375 # as in previous test.
376 test_expect_success 'right alignment formatting at the nth column with --graph. i18n.logOutputEncoding' '
377 git -c i18n.logOutputEncoding=$test_encoding log --graph --pretty="tformat:%h %>|(40)%s" >actual &&
378 iconv -f utf-8 -t $test_encoding >expected <<-EOF &&
382 * $head4 $(commit_msg)
384 test_cmp expected actual
387 test_expect_success 'right alignment formatting with no padding' '
388 git log --pretty="tformat:%>(1)%s" >actual &&
389 cat <<-EOF >expected &&
395 test_cmp expected actual
398 test_expect_success 'right alignment formatting with no padding and with --graph' '
399 git log --graph --pretty="tformat:%>(1)%s" >actual &&
400 cat <<-EOF >expected &&
406 test_cmp expected actual
409 test_expect_success 'right alignment formatting with no padding. i18n.logOutputEncoding' '
410 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%>(1)%s" >actual &&
411 cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
417 test_cmp expected actual
420 test_expect_success 'center alignment formatting' '
421 git log --pretty="tformat:%><(40)%s" >actual &&
422 qz_to_tab_space <<-EOF >expected &&
428 test_cmp expected actual
431 test_expect_success 'center alignment formatting. i18n.logOutputEncoding' '
432 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(40)%s" >actual &&
433 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
439 test_cmp expected actual
441 test_expect_success 'center alignment formatting at the nth column' '
442 git log --pretty="tformat:%h %><|(40)%s" >actual &&
443 qz_to_tab_space <<-EOF >expected &&
447 $head4 $(commit_msg) Z
449 test_cmp expected actual
452 test_expect_success 'center alignment formatting at the nth column' '
453 COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
454 qz_to_tab_space <<-EOF >expected &&
458 $head4 $(commit_msg) Z
460 test_cmp expected actual
463 test_expect_success 'center alignment formatting at the nth column. i18n.logOutputEncoding' '
464 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%h %><|(40)%s" >actual &&
465 qz_to_tab_space <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
469 $head4 $(commit_msg) Z
471 test_cmp expected actual
474 test_expect_success 'center alignment formatting with no padding' '
475 git log --pretty="tformat:%><(1)%s" >actual &&
476 cat <<-EOF >expected &&
482 test_cmp expected actual
485 # save HEAD's SHA-1 digest (with no abbreviations) to use it below
486 # as far as the next test amends HEAD
487 old_head1=$(git rev-parse --verify HEAD~0)
488 test_expect_success 'center alignment formatting with no padding. i18n.logOutputEncoding' '
489 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%><(1)%s" >actual &&
490 cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
496 test_cmp expected actual
499 test_expect_success 'left/right alignment formatting with stealing' '
500 git commit --amend -m short --author "long long long <long@me.com>" &&
501 git log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
502 cat <<-\EOF >expected &&
508 test_cmp expected actual
510 test_expect_success 'left/right alignment formatting with stealing. i18n.logOutputEncoding' '
511 git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)% an" >actual &&
512 cat <<-\EOF | iconv -f utf-8 -t $test_encoding >expected &&
518 test_cmp expected actual
521 test_expect_success 'strbuf_utf8_replace() not producing NUL' '
522 git log --color --pretty="tformat:%<(10,trunc)%s%>>(10,ltrunc)%C(auto)%d" |
528 # ISO strict date format
529 test_expect_success 'ISO and ISO-strict date formats display the same values' '
530 git log --format=%ai%n%ci |
531 sed -e "s/ /T/; s/ //; s/..\$/:&/" >expected &&
532 git log --format=%aI%n%cI >actual &&
533 test_cmp expected actual
536 test_expect_success 'short date' '
537 git log --format=%ad%n%cd --date=short >expected &&
538 git log --format=%as%n%cs >actual &&
539 test_cmp expected actual
542 # get new digests (with no abbreviations)
543 test_expect_success 'set up log decoration tests' '
544 head1=$(git rev-parse --verify HEAD~0) &&
545 head2=$(git rev-parse --verify HEAD~1)
548 test_expect_success 'log decoration properly follows tag chain' '
549 git tag -a tag1 -m tag1 &&
550 git tag -a tag2 -m tag2 tag1 &&
552 git commit --amend -m shorter &&
553 git log --no-walk --tags --pretty="%H %d" --decorate=full >actual &&
554 cat <<-EOF >expected &&
555 $head2 (tag: refs/tags/message-one)
556 $old_head1 (tag: refs/tags/message-two)
557 $head1 (tag: refs/tags/tag2)
559 sort -k3 actual >actual1 &&
560 test_cmp expected actual1
563 test_expect_success 'clean log decoration' '
564 git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
565 cat >expected <<-EOF &&
566 $head2 tag: refs/tags/message-one
567 $old_head1 tag: refs/tags/message-two
568 $head1 tag: refs/tags/tag2
570 sort -k3 actual >actual1 &&
571 test_cmp expected actual1
575 Signed-off-by: A U Thor <author@example.com>
576 Acked-by: A U Thor <author@example.com>
577 [ v2 updated patch description ]
578 Signed-off-by: A U Thor
583 perl -0pe 's/\n\s+/ /g'
586 test_expect_success 'set up trailer tests' '
587 echo "Some contents" >trailerfile &&
588 git add trailerfile &&
589 git commit -F - <<-EOF
590 trailers: this commit message has trailers
592 This commit is a test commit with trailers at the end. We parse this
593 message and display the trailers using %(trailers).
599 test_expect_success 'pretty format %(trailers) shows trailers' '
600 git log --no-walk --pretty="%(trailers)" >actual &&
605 test_cmp expect actual
608 test_expect_success 'pretty format %(trailers:) enables no options' '
609 git log --no-walk --pretty="%(trailers:)" >actual &&
610 # "expect" the same as the test above
611 test_cmp expect actual
614 test_expect_success '%(trailers:only) shows only "key: value" trailers' '
615 git log --no-walk --pretty="%(trailers:only)" >actual &&
617 grep -v patch.description <trailers &&
620 test_cmp expect actual
623 test_expect_success '%(trailers:only=yes) shows only "key: value" trailers' '
624 git log --no-walk --pretty=format:"%(trailers:only=yes)" >actual &&
625 grep -v patch.description <trailers >expect &&
626 test_cmp expect actual
629 test_expect_success '%(trailers:only=no) shows all trailers' '
630 git log --no-walk --pretty=format:"%(trailers:only=no)" >actual &&
631 cat trailers >expect &&
632 test_cmp expect actual
635 test_expect_success '%(trailers:only=no,only=true) shows only "key: value" trailers' '
636 git log --no-walk --pretty=format:"%(trailers:only=yes)" >actual &&
637 grep -v patch.description <trailers >expect &&
638 test_cmp expect actual
641 test_expect_success '%(trailers:unfold) unfolds trailers' '
642 git log --no-walk --pretty="%(trailers:unfold)" >actual &&
647 test_cmp expect actual
650 test_expect_success ':only and :unfold work together' '
651 git log --no-walk --pretty="%(trailers:only,unfold)" >actual &&
652 git log --no-walk --pretty="%(trailers:unfold,only)" >reverse &&
653 test_cmp actual reverse &&
655 grep -v patch.description <trailers | unfold &&
658 test_cmp expect actual
661 test_expect_success 'pretty format %(trailers:key=foo) shows that trailer' '
662 git log --no-walk --pretty="format:%(trailers:key=Acked-by)" >actual &&
663 echo "Acked-by: A U Thor <author@example.com>" >expect &&
664 test_cmp expect actual
667 test_expect_success 'pretty format %(trailers:key=foo) is case insensitive' '
668 git log --no-walk --pretty="format:%(trailers:key=AcKed-bY)" >actual &&
669 echo "Acked-by: A U Thor <author@example.com>" >expect &&
670 test_cmp expect actual
673 test_expect_success 'pretty format %(trailers:key=foo:) trailing colon also works' '
674 git log --no-walk --pretty="format:%(trailers:key=Acked-by:)" >actual &&
675 echo "Acked-by: A U Thor <author@example.com>" >expect &&
676 test_cmp expect actual
679 test_expect_success 'pretty format %(trailers:key=foo) multiple keys' '
680 git log --no-walk --pretty="format:%(trailers:key=Acked-by:,key=Signed-off-By)" >actual &&
681 grep -v patch.description <trailers >expect &&
682 test_cmp expect actual
685 test_expect_success '%(trailers:key=nonexistent) becomes empty' '
686 git log --no-walk --pretty="x%(trailers:key=Nacked-by)x" >actual &&
688 test_cmp expect actual
691 test_expect_success '%(trailers:key=foo) handles multiple lines even if folded' '
692 git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by)" >actual &&
693 grep -v patch.description <trailers | grep -v Acked-by >expect &&
694 test_cmp expect actual
697 test_expect_success '%(trailers:key=foo,unfold) properly unfolds' '
698 git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by,unfold)" >actual &&
699 unfold <trailers | grep Signed-off-by >expect &&
700 test_cmp expect actual
703 test_expect_success 'pretty format %(trailers:key=foo,only=no) also includes nontrailer lines' '
704 git log --no-walk --pretty="format:%(trailers:key=Acked-by,only=no)" >actual &&
706 echo "Acked-by: A U Thor <author@example.com>" &&
707 grep patch.description <trailers
709 test_cmp expect actual
712 test_expect_success '%(trailers:key) without value is error' '
713 git log --no-walk --pretty="tformat:%(trailers:key)" >actual &&
714 echo "%(trailers:key)" >expect &&
715 test_cmp expect actual
718 test_expect_success '%(trailers:keyonly) shows only keys' '
719 git log --no-walk --pretty="format:%(trailers:keyonly)" >actual &&
723 "[ v2 updated patch description ]" \
724 "Signed-off-by" >expect &&
725 test_cmp expect actual
728 test_expect_success '%(trailers:key=foo,keyonly) shows only key' '
729 git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly)" >actual &&
730 echo "Acked-by" >expect &&
731 test_cmp expect actual
734 test_expect_success '%(trailers:key=foo,valueonly) shows only value' '
735 git log --no-walk --pretty="format:%(trailers:key=Acked-by,valueonly)" >actual &&
736 echo "A U Thor <author@example.com>" >expect &&
737 test_cmp expect actual
740 test_expect_success '%(trailers:valueonly) shows only values' '
741 git log --no-walk --pretty="format:%(trailers:valueonly)" >actual &&
743 "A U Thor <author@example.com>" \
744 "A U Thor <author@example.com>" \
745 "[ v2 updated patch description ]" \
747 " <author@example.com>" >expect &&
748 test_cmp expect actual
751 test_expect_success '%(trailers:key=foo,keyonly,valueonly) shows nothing' '
752 git log --no-walk --pretty="format:%(trailers:key=Acked-by,keyonly,valueonly)" >actual &&
754 test_cmp expect actual
757 test_expect_success 'pretty format %(trailers:separator) changes separator' '
758 git log --no-walk --pretty=format:"X%(trailers:separator=%x00)X" >actual &&
760 printf "XSigned-off-by: A U Thor <author@example.com>\0" &&
761 printf "Acked-by: A U Thor <author@example.com>\0" &&
762 printf "[ v2 updated patch description ]\0" &&
763 printf "Signed-off-by: A U Thor\n <author@example.com>X"
765 test_cmp expect actual
768 test_expect_success 'pretty format %(trailers:separator=X,unfold) changes separator' '
769 git log --no-walk --pretty=format:"X%(trailers:separator=%x00,unfold)X" >actual &&
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 <author@example.com>X"
776 test_cmp expect actual
779 test_expect_success 'pretty format %(trailers:key_value_separator) changes key-value separator' '
780 git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00)X" >actual &&
782 printf "XSigned-off-by\0A U Thor <author@example.com>\n" &&
783 printf "Acked-by\0A U Thor <author@example.com>\n" &&
784 printf "[ v2 updated patch description ]\n" &&
785 printf "Signed-off-by\0A U Thor\n <author@example.com>\nX"
787 test_cmp expect actual
790 test_expect_success 'pretty format %(trailers:key_value_separator,unfold) changes key-value separator' '
791 git log --no-walk --pretty=format:"X%(trailers:key_value_separator=%x00,unfold)X" >actual &&
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 <author@example.com>\nX"
798 test_cmp expect actual
801 test_expect_success 'pretty format %(trailers:separator,key_value_separator) changes both separators' '
802 git log --no-walk --pretty=format:"%(trailers:separator=%x00,key_value_separator=%x00%x00,unfold)" >actual &&
804 printf "Signed-off-by\0\0A U Thor <author@example.com>\0" &&
805 printf "Acked-by\0\0A U Thor <author@example.com>\0" &&
806 printf "[ v2 updated patch description ]\0" &&
807 printf "Signed-off-by\0\0A U Thor <author@example.com>"
809 test_cmp expect actual
812 test_expect_success 'pretty format %(trailers) combining separator/key/keyonly/valueonly' '
813 git commit --allow-empty -F - <<-\EOF &&
816 The fix is explained here
821 git commit --allow-empty -F - <<-\EOF &&
824 The fix is explained here
830 git commit --allow-empty -F - <<-\EOF &&
831 Does not close any tickets
834 git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,valueonly)" HEAD~3.. >actual &&
836 "Does not close any tickets" \
837 "Another fix #567, #890" \
838 "Important fix #1234" >expect &&
839 test_cmp expect actual &&
841 git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,keyonly)" HEAD~3.. >actual &&
843 "Does not close any tickets" \
844 "Another fix Closes, Closes" \
845 "Important fix Closes" >expect &&
846 test_cmp expect actual
849 test_expect_success 'trailer parsing not fooled by --- line' '
850 git commit --allow-empty -F - <<-\EOF &&
853 This is the body. The message has a "---" line which would confuse a
854 message+patch parser. But here we know we have only a commit message,
865 echo "trailer: right" &&
868 git log --no-walk --format="%(trailers)" >actual &&
869 test_cmp expect actual
872 test_expect_success 'set up %S tests' '
873 git checkout --orphan source-a &&
876 git checkout -b source-b HEAD^ &&
880 test_expect_success 'log --format=%S paints branch names' '
881 cat >expect <<-\EOF &&
886 git log --format=%S source-a source-b >actual &&
887 test_cmp expect actual
890 test_expect_success 'log --format=%S paints tag names' '
891 git tag -m tagged source-tag &&
892 cat >expect <<-\EOF &&
897 git log --format=%S source-tag source-a >actual &&
898 test_cmp expect actual
901 test_expect_success 'log --format=%S paints symmetric ranges' '
902 cat >expect <<-\EOF &&
906 git log --format=%S source-a...source-b >actual &&
907 test_cmp expect actual
910 test_expect_success '%S in git log --format works with other placeholders (part 1)' '
911 git log --format="source-b %h" source-b >expect &&
912 git log --format="%S %h" source-b >actual &&
913 test_cmp expect actual
916 test_expect_success '%S in git log --format works with other placeholders (part 2)' '
917 git log --format="%h source-b" source-b >expect &&
918 git log --format="%h %S" source-b >actual &&
919 test_cmp expect actual
922 test_expect_success 'log --pretty=reference' '
923 git log --pretty="tformat:%h (%s, %as)" >expect &&
924 git log --pretty=reference >actual &&
925 test_cmp expect actual
928 test_expect_success 'log --pretty=reference with log.date is overridden by short date' '
929 git log --pretty="tformat:%h (%s, %as)" >expect &&
930 test_config log.date rfc &&
931 git log --pretty=reference >actual &&
932 test_cmp expect actual
935 test_expect_success 'log --pretty=reference with explicit date overrides short date' '
936 git log --date=rfc --pretty="tformat:%h (%s, %ad)" >expect &&
937 git log --date=rfc --pretty=reference >actual &&
938 test_cmp expect actual
941 test_expect_success 'log --pretty=reference is never unabbreviated' '
942 git log --pretty="tformat:%h (%s, %as)" >expect &&
943 git log --no-abbrev-commit --pretty=reference >actual &&
944 test_cmp expect actual
947 test_expect_success 'log --pretty=reference is never decorated' '
948 git log --pretty="tformat:%h (%s, %as)" >expect &&
949 git log --decorate=short --pretty=reference >actual &&
950 test_cmp expect actual
953 test_expect_success 'log --pretty=reference does not output reflog info' '
954 git log --walk-reflogs --pretty="tformat:%h (%s, %as)" >expect &&
955 git log --walk-reflogs --pretty=reference >actual &&
956 test_cmp expect actual
959 test_expect_success 'log --pretty=reference is colored appropriately' '
960 git log --color=always --pretty="tformat:%C(auto)%h (%s, %as)" >expect &&
961 git log --color=always --pretty=reference >actual &&
962 test_cmp expect actual