]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4202-log.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / t / t4202-log.sh
1 #!/bin/sh
2
3 test_description='git log'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY/lib-gpg.sh"
10 . "$TEST_DIRECTORY/lib-terminal.sh"
11 . "$TEST_DIRECTORY/lib-log-graph.sh"
12
13 test_cmp_graph () {
14 lib_test_cmp_graph --format=%s "$@"
15 }
16
17 test_expect_success setup '
18
19 echo one >one &&
20 git add one &&
21 test_tick &&
22 git commit -m initial &&
23
24 echo ichi >one &&
25 git add one &&
26 test_tick &&
27 git commit -m second &&
28
29 git mv one ichi &&
30 test_tick &&
31 git commit -m third &&
32
33 cp ichi ein &&
34 git add ein &&
35 test_tick &&
36 git commit -m fourth &&
37
38 mkdir a &&
39 echo ni >a/two &&
40 git add a/two &&
41 test_tick &&
42 git commit -m fifth &&
43
44 git rm a/two &&
45 test_tick &&
46 git commit -m sixth
47
48 '
49
50 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
51 test_expect_success 'pretty' '
52
53 git log --pretty="format:%s" > actual &&
54 test_cmp expect actual
55 '
56
57 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
58 test_expect_success 'pretty (tformat)' '
59
60 git log --pretty="tformat:%s" > actual &&
61 test_cmp expect actual
62 '
63
64 test_expect_success 'pretty (shortcut)' '
65
66 git log --pretty="%s" > actual &&
67 test_cmp expect actual
68 '
69
70 test_expect_success 'format' '
71
72 git log --format="%s" > actual &&
73 test_cmp expect actual
74 '
75
76 cat > expect << EOF
77 This is
78 the sixth
79 commit.
80 This is
81 the fifth
82 commit.
83 EOF
84
85 test_expect_success 'format %w(11,1,2)' '
86
87 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
88 test_cmp expect actual
89 '
90
91 test_expect_success 'format %w(,1,2)' '
92
93 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
94 test_cmp expect actual
95 '
96
97 cat > expect << EOF
98 $(git rev-parse --short :/sixth ) sixth
99 $(git rev-parse --short :/fifth ) fifth
100 $(git rev-parse --short :/fourth ) fourth
101 $(git rev-parse --short :/third ) third
102 $(git rev-parse --short :/second ) second
103 $(git rev-parse --short :/initial) initial
104 EOF
105 test_expect_success 'oneline' '
106
107 git log --oneline > actual &&
108 test_cmp expect actual
109 '
110
111 test_expect_success 'diff-filter=A' '
112
113 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
114 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
115 printf "fifth\nfourth\nthird\ninitial" > expect &&
116 test_cmp expect actual &&
117 test_cmp expect actual-separate
118
119 '
120
121 test_expect_success 'diff-filter=M' '
122
123 git log --pretty="format:%s" --diff-filter=M HEAD >actual &&
124 printf "second" >expect &&
125 test_cmp expect actual
126
127 '
128
129 test_expect_success 'diff-filter=D' '
130
131 git log --no-renames --pretty="format:%s" --diff-filter=D HEAD >actual &&
132 printf "sixth\nthird" >expect &&
133 test_cmp expect actual
134
135 '
136
137 test_expect_success 'diff-filter=R' '
138
139 git log -M --pretty="format:%s" --diff-filter=R HEAD >actual &&
140 printf "third" >expect &&
141 test_cmp expect actual
142
143 '
144
145 test_expect_success 'multiple --diff-filter bits' '
146
147 git log -M --pretty="format:%s" --diff-filter=R HEAD >expect &&
148 git log -M --pretty="format:%s" --diff-filter=Ra HEAD >actual &&
149 test_cmp expect actual &&
150 git log -M --pretty="format:%s" --diff-filter=aR HEAD >actual &&
151 test_cmp expect actual &&
152 git log -M --pretty="format:%s" \
153 --diff-filter=a --diff-filter=R HEAD >actual &&
154 test_cmp expect actual
155
156 '
157
158 test_expect_success 'diff-filter=C' '
159
160 git log -C -C --pretty="format:%s" --diff-filter=C HEAD >actual &&
161 printf "fourth" >expect &&
162 test_cmp expect actual
163
164 '
165
166 test_expect_success 'git log --follow' '
167
168 git log --follow --pretty="format:%s" ichi >actual &&
169 printf "third\nsecond\ninitial" >expect &&
170 test_cmp expect actual
171 '
172
173 test_expect_success 'git config log.follow works like --follow' '
174 test_config log.follow true &&
175 git log --pretty="format:%s" ichi >actual &&
176 printf "third\nsecond\ninitial" >expect &&
177 test_cmp expect actual
178 '
179
180 test_expect_success 'git config log.follow does not die with multiple paths' '
181 test_config log.follow true &&
182 git log --pretty="format:%s" ichi ein
183 '
184
185 test_expect_success 'git config log.follow does not die with no paths' '
186 test_config log.follow true &&
187 git log --
188 '
189
190 test_expect_success 'git config log.follow is overridden by --no-follow' '
191 test_config log.follow true &&
192 git log --no-follow --pretty="format:%s" ichi >actual &&
193 printf "third" >expect &&
194 test_cmp expect actual
195 '
196
197 # Note that these commits are intentionally listed out of order.
198 last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
199 cat > expect << EOF
200 $(git rev-parse --short :/sixth ) sixth
201 $(git rev-parse --short :/fifth ) fifth
202 $(git rev-parse --short :/fourth) fourth
203 EOF
204 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
205 git log --no-walk --oneline $last_three > actual &&
206 test_cmp expect actual
207 '
208
209 test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
210 git log --no-walk=sorted --oneline $last_three > actual &&
211 test_cmp expect actual
212 '
213
214 cat > expect << EOF
215 === $(git rev-parse --short :/sixth ) sixth
216 === $(git rev-parse --short :/fifth ) fifth
217 === $(git rev-parse --short :/fourth) fourth
218 EOF
219 test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
220 git log --line-prefix="=== " --no-walk --oneline $last_three > actual &&
221 test_cmp expect actual
222 '
223
224 cat > expect << EOF
225 $(git rev-parse --short :/fourth) fourth
226 $(git rev-parse --short :/sixth ) sixth
227 $(git rev-parse --short :/fifth ) fifth
228 EOF
229 test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
230 git log --no-walk=unsorted --oneline $last_three > actual &&
231 test_cmp expect actual
232 '
233
234 test_expect_success 'git show <commits> leaves list of commits as given' '
235 git show --oneline -s $last_three > actual &&
236 test_cmp expect actual
237 '
238
239 test_expect_success 'setup case sensitivity tests' '
240 echo case >one &&
241 test_tick &&
242 git add one &&
243 git commit -a -m Second
244 '
245
246 test_expect_success 'log --grep' '
247 echo second >expect &&
248 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
249 test_cmp expect actual
250 '
251
252 cat > expect << EOF
253 second
254 initial
255 EOF
256 test_expect_success 'log --invert-grep --grep' '
257 # Fixed
258 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
259 test_cmp expect actual &&
260
261 # POSIX basic
262 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
263 test_cmp expect actual &&
264
265 # POSIX extended
266 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
267 test_cmp expect actual &&
268
269 # PCRE
270 if test_have_prereq PCRE
271 then
272 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
273 test_cmp expect actual
274 fi
275 '
276
277 test_expect_success 'log --invert-grep --grep -i' '
278 echo initial >expect &&
279
280 # Fixed
281 git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
282 test_cmp expect actual &&
283
284 # POSIX basic
285 git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
286 test_cmp expect actual &&
287
288 # POSIX extended
289 git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
290 test_cmp expect actual &&
291
292 # PCRE
293 if test_have_prereq PCRE
294 then
295 git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
296 test_cmp expect actual
297 fi
298 '
299
300 test_expect_success 'log --grep option parsing' '
301 echo second >expect &&
302 git log -1 --pretty="tformat:%s" --grep sec >actual &&
303 test_cmp expect actual &&
304 test_must_fail git log -1 --pretty="tformat:%s" --grep
305 '
306
307 test_expect_success 'log -i --grep' '
308 echo Second >expect &&
309 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
310 test_cmp expect actual
311 '
312
313 test_expect_success 'log --grep -i' '
314 echo Second >expect &&
315
316 # Fixed
317 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
318 test_cmp expect actual &&
319
320 # POSIX basic
321 git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
322 test_cmp expect actual &&
323
324 # POSIX extended
325 git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
326 test_cmp expect actual &&
327
328 # PCRE
329 if test_have_prereq PCRE
330 then
331 git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
332 test_cmp expect actual
333 fi
334 '
335
336 test_expect_success 'log -F -E --grep=<ere> uses ere' '
337 echo second >expect &&
338 # basic would need \(s\) to do the same
339 git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
340 test_cmp expect actual
341 '
342
343 test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
344 test_when_finished "rm -rf num_commits" &&
345 git init num_commits &&
346 (
347 cd num_commits &&
348 test_commit 1d &&
349 test_commit 2e
350 ) &&
351
352 # In PCRE \d in [\d] is like saying "0-9", and matches the 2
353 # in 2e...
354 echo 2e >expect &&
355 git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
356 test_cmp expect actual &&
357
358 # ...in POSIX basic and extended it is the same as [d],
359 # i.e. "d", which matches 1d, but does not match 2e.
360 echo 1d >expect &&
361 git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
362 test_cmp expect actual
363 '
364
365 test_expect_success 'log with grep.patternType configuration' '
366 git -c grep.patterntype=fixed \
367 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
368 test_must_be_empty actual
369 '
370
371 test_expect_success 'log with grep.patternType configuration and command line' '
372 echo second >expect &&
373 git -c grep.patterntype=fixed \
374 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
375 test_cmp expect actual
376 '
377
378 test_expect_success !FAIL_PREREQS 'log with various grep.patternType configurations & command-lines' '
379 git init pattern-type &&
380 (
381 cd pattern-type &&
382 test_commit 1 file A &&
383
384 # The tagname is overridden here because creating a
385 # tag called "(1|2)" as test_commit would otherwise
386 # implicitly do would fail on e.g. MINGW.
387 test_commit "(1|2)" file B 2 &&
388
389 echo "(1|2)" >expect.fixed &&
390 cp expect.fixed expect.basic &&
391 cp expect.fixed expect.extended &&
392 cp expect.fixed expect.perl &&
393
394 # A strcmp-like match with fixed.
395 git -c grep.patternType=fixed log --pretty=tformat:%s \
396 --grep="(1|2)" >actual.fixed &&
397
398 # POSIX basic matches (, | and ) literally.
399 git -c grep.patternType=basic log --pretty=tformat:%s \
400 --grep="(.|.)" >actual.basic &&
401
402 # POSIX extended needs to have | escaped to match it
403 # literally, whereas under basic this is the same as
404 # (|2), i.e. it would also match "1". This test checks
405 # for extended by asserting that it is not matching
406 # what basic would match.
407 git -c grep.patternType=extended log --pretty=tformat:%s \
408 --grep="\|2" >actual.extended &&
409 if test_have_prereq PCRE
410 then
411 # Only PCRE would match [\d]\| with only
412 # "(1|2)" due to [\d]. POSIX basic would match
413 # both it and "1" since similarly to the
414 # extended match above it is the same as
415 # \([\d]\|\). POSIX extended would
416 # match neither.
417 git -c grep.patternType=perl log --pretty=tformat:%s \
418 --grep="[\d]\|" >actual.perl &&
419 test_cmp expect.perl actual.perl
420 fi &&
421 test_cmp expect.fixed actual.fixed &&
422 test_cmp expect.basic actual.basic &&
423 test_cmp expect.extended actual.extended &&
424
425 git log --pretty=tformat:%s -F \
426 --grep="(1|2)" >actual.fixed.short-arg &&
427 git log --pretty=tformat:%s -E \
428 --grep="\|2" >actual.extended.short-arg &&
429 if test_have_prereq PCRE
430 then
431 git log --pretty=tformat:%s -P \
432 --grep="[\d]\|" >actual.perl.short-arg
433 else
434 test_must_fail git log -P \
435 --grep="[\d]\|"
436 fi &&
437 test_cmp expect.fixed actual.fixed.short-arg &&
438 test_cmp expect.extended actual.extended.short-arg &&
439 if test_have_prereq PCRE
440 then
441 test_cmp expect.perl actual.perl.short-arg
442 fi &&
443
444 git log --pretty=tformat:%s --fixed-strings \
445 --grep="(1|2)" >actual.fixed.long-arg &&
446 git log --pretty=tformat:%s --basic-regexp \
447 --grep="(.|.)" >actual.basic.long-arg &&
448 git log --pretty=tformat:%s --extended-regexp \
449 --grep="\|2" >actual.extended.long-arg &&
450 if test_have_prereq PCRE
451 then
452 git log --pretty=tformat:%s --perl-regexp \
453 --grep="[\d]\|" >actual.perl.long-arg &&
454 test_cmp expect.perl actual.perl.long-arg
455 else
456 test_must_fail git log --perl-regexp \
457 --grep="[\d]\|"
458 fi &&
459 test_cmp expect.fixed actual.fixed.long-arg &&
460 test_cmp expect.basic actual.basic.long-arg &&
461 test_cmp expect.extended actual.extended.long-arg
462 )
463 '
464
465 for cmd in show whatchanged reflog format-patch
466 do
467 case "$cmd" in
468 format-patch) myarg="HEAD~.." ;;
469 *) myarg= ;;
470 esac
471
472 test_expect_success "$cmd: understands grep.patternType, like 'log'" '
473 git init "pattern-type-$cmd" &&
474 (
475 cd "pattern-type-$cmd" &&
476 test_commit 1 file A &&
477 test_commit "(1|2)" file B 2 &&
478
479 git -c grep.patternType=fixed $cmd --grep="..." $myarg >actual &&
480 test_must_be_empty actual &&
481
482 git -c grep.patternType=basic $cmd --grep="..." $myarg >actual &&
483 test_file_not_empty actual
484 )
485 '
486 done
487
488 test_expect_success 'log --author' '
489 cat >expect <<-\EOF &&
490 Author: <BOLD;RED>A U<RESET> Thor <author@example.com>
491 EOF
492 git log -1 --color=always --author="A U" >log &&
493 grep Author log >actual.raw &&
494 test_decode_color <actual.raw >actual &&
495 test_cmp expect actual
496 '
497
498 test_expect_success 'log --committer' '
499 cat >expect <<-\EOF &&
500 Commit: C O Mitter <committer@<BOLD;RED>example<RESET>.com>
501 EOF
502 git log -1 --color=always --pretty=fuller --committer="example" >log &&
503 grep "Commit:" log >actual.raw &&
504 test_decode_color <actual.raw >actual &&
505 test_cmp expect actual
506 '
507
508 test_expect_success 'log -i --grep with color' '
509 cat >expect <<-\EOF &&
510 <BOLD;RED>Sec<RESET>ond
511 <BOLD;RED>sec<RESET>ond
512 EOF
513 git log --color=always -i --grep=^sec >log &&
514 grep -i sec log >actual.raw &&
515 test_decode_color <actual.raw >actual &&
516 test_cmp expect actual
517 '
518
519 test_expect_success '-c color.grep.selected log --grep' '
520 cat >expect <<-\EOF &&
521 <GREEN>th<RESET><BOLD;RED>ir<RESET><GREEN>d<RESET>
522 EOF
523 git -c color.grep.selected="green" log --color=always --grep=ir >log &&
524 grep ir log >actual.raw &&
525 test_decode_color <actual.raw >actual &&
526 test_cmp expect actual
527 '
528
529 test_expect_success '-c color.grep.matchSelected log --grep' '
530 cat >expect <<-\EOF &&
531 <BLUE>i<RESET>n<BLUE>i<RESET>t<BLUE>i<RESET>al
532 EOF
533 git -c color.grep.matchSelected="blue" log --color=always --grep=i >log &&
534 grep al log >actual.raw &&
535 test_decode_color <actual.raw >actual &&
536 test_cmp expect actual
537 '
538
539 cat > expect <<EOF
540 * Second
541 * sixth
542 * fifth
543 * fourth
544 * third
545 * second
546 * initial
547 EOF
548
549 test_expect_success 'simple log --graph' '
550 test_cmp_graph
551 '
552
553 cat > expect <<EOF
554 123 * Second
555 123 * sixth
556 123 * fifth
557 123 * fourth
558 123 * third
559 123 * second
560 123 * initial
561 EOF
562
563 test_expect_success 'simple log --graph --line-prefix="123 "' '
564 test_cmp_graph --line-prefix="123 "
565 '
566
567 test_expect_success 'set up merge history' '
568 git checkout -b side HEAD~4 &&
569 test_commit side-1 1 1 &&
570 test_commit side-2 2 2 &&
571 git checkout main &&
572 git merge side
573 '
574
575 cat > expect <<\EOF
576 * Merge branch 'side'
577 |\
578 | * side-2
579 | * side-1
580 * | Second
581 * | sixth
582 * | fifth
583 * | fourth
584 |/
585 * third
586 * second
587 * initial
588 EOF
589
590 test_expect_success 'log --graph with merge' '
591 test_cmp_graph --date-order
592 '
593
594 cat > expect <<\EOF
595 | | | * Merge branch 'side'
596 | | | |\
597 | | | | * side-2
598 | | | | * side-1
599 | | | * | Second
600 | | | * | sixth
601 | | | * | fifth
602 | | | * | fourth
603 | | | |/
604 | | | * third
605 | | | * second
606 | | | * initial
607 EOF
608
609 test_expect_success 'log --graph --line-prefix="| | | " with merge' '
610 test_cmp_graph --line-prefix="| | | " --date-order
611 '
612
613 cat > expect.colors <<\EOF
614 * Merge branch 'side'
615 <BLUE>|<RESET><CYAN>\<RESET>
616 <BLUE>|<RESET> * side-2
617 <BLUE>|<RESET> * side-1
618 * <CYAN>|<RESET> Second
619 * <CYAN>|<RESET> sixth
620 * <CYAN>|<RESET> fifth
621 * <CYAN>|<RESET> fourth
622 <CYAN>|<RESET><CYAN>/<RESET>
623 * third
624 * second
625 * initial
626 EOF
627
628 test_expect_success 'log --graph with merge with log.graphColors' '
629 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
630 lib_test_cmp_colored_graph --date-order --format=%s
631 '
632
633 test_expect_success 'log --raw --graph -m with merge' '
634 git log --raw --graph --oneline -m main | head -n 500 >actual &&
635 grep "initial" actual
636 '
637
638 test_expect_success 'diff-tree --graph' '
639 git diff-tree --graph main^ | head -n 500 >actual &&
640 grep "one" actual
641 '
642
643 cat > expect <<\EOF
644 * commit main
645 |\ Merge: A B
646 | | Author: A U Thor <author@example.com>
647 | |
648 | | Merge branch 'side'
649 | |
650 | * commit tags/side-2
651 | | Author: A U Thor <author@example.com>
652 | |
653 | | side-2
654 | |
655 | * commit tags/side-1
656 | | Author: A U Thor <author@example.com>
657 | |
658 | | side-1
659 | |
660 * | commit main~1
661 | | Author: A U Thor <author@example.com>
662 | |
663 | | Second
664 | |
665 * | commit main~2
666 | | Author: A U Thor <author@example.com>
667 | |
668 | | sixth
669 | |
670 * | commit main~3
671 | | Author: A U Thor <author@example.com>
672 | |
673 | | fifth
674 | |
675 * | commit main~4
676 |/ Author: A U Thor <author@example.com>
677 |
678 | fourth
679 |
680 * commit tags/side-1~1
681 | Author: A U Thor <author@example.com>
682 |
683 | third
684 |
685 * commit tags/side-1~2
686 | Author: A U Thor <author@example.com>
687 |
688 | second
689 |
690 * commit tags/side-1~3
691 Author: A U Thor <author@example.com>
692
693 initial
694 EOF
695
696 test_expect_success 'log --graph with full output' '
697 git log --graph --date-order --pretty=short |
698 git name-rev --name-only --annotate-stdin |
699 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
700 test_cmp expect actual
701 '
702
703 test_expect_success 'set up more tangled history' '
704 git checkout -b tangle HEAD~6 &&
705 test_commit tangle-a tangle-a a &&
706 git merge main~3 &&
707 git merge side~1 &&
708 git checkout main &&
709 git merge tangle &&
710 git checkout -b reach &&
711 test_commit reach &&
712 git checkout main &&
713 git checkout -b octopus-a &&
714 test_commit octopus-a &&
715 git checkout main &&
716 git checkout -b octopus-b &&
717 test_commit octopus-b &&
718 git checkout main &&
719 test_commit seventh &&
720 git merge octopus-a octopus-b &&
721 git merge reach
722 '
723
724 cat > expect <<\EOF
725 * Merge tag 'reach'
726 |\
727 | \
728 | \
729 *-. \ Merge tags 'octopus-a' and 'octopus-b'
730 |\ \ \
731 * | | | seventh
732 | | * | octopus-b
733 | |/ /
734 |/| |
735 | * | octopus-a
736 |/ /
737 | * reach
738 |/
739 * Merge branch 'tangle'
740 |\
741 | * Merge branch 'side' (early part) into tangle
742 | |\
743 | * \ Merge branch 'main' (early part) into tangle
744 | |\ \
745 | * | | tangle-a
746 * | | | Merge branch 'side'
747 |\ \ \ \
748 | * | | | side-2
749 | | |_|/
750 | |/| |
751 | * | | side-1
752 * | | | Second
753 * | | | sixth
754 | |_|/
755 |/| |
756 * | | fifth
757 * | | fourth
758 |/ /
759 * / third
760 |/
761 * second
762 * initial
763 EOF
764
765 test_expect_success 'log --graph with merge' '
766 test_cmp_graph --date-order
767 '
768
769 test_expect_success 'log.decorate configuration' '
770 git log --oneline --no-decorate >expect.none &&
771 git log --oneline --decorate >expect.short &&
772 git log --oneline --decorate=full >expect.full &&
773
774 echo "[log] decorate" >>.git/config &&
775 git log --oneline >actual &&
776 test_cmp expect.short actual &&
777
778 test_config log.decorate true &&
779 git log --oneline >actual &&
780 test_cmp expect.short actual &&
781 git log --oneline --decorate=full >actual &&
782 test_cmp expect.full actual &&
783 git log --oneline --decorate=no >actual &&
784 test_cmp expect.none actual &&
785
786 test_config log.decorate no &&
787 git log --oneline >actual &&
788 test_cmp expect.none actual &&
789 git log --oneline --decorate >actual &&
790 test_cmp expect.short actual &&
791 git log --oneline --decorate=full >actual &&
792 test_cmp expect.full actual &&
793
794 test_config log.decorate 1 &&
795 git log --oneline >actual &&
796 test_cmp expect.short actual &&
797 git log --oneline --decorate=full >actual &&
798 test_cmp expect.full actual &&
799 git log --oneline --decorate=no >actual &&
800 test_cmp expect.none actual &&
801
802 test_config log.decorate short &&
803 git log --oneline >actual &&
804 test_cmp expect.short actual &&
805 git log --oneline --no-decorate >actual &&
806 test_cmp expect.none actual &&
807 git log --oneline --decorate=full >actual &&
808 test_cmp expect.full actual &&
809
810 test_config log.decorate full &&
811 git log --oneline >actual &&
812 test_cmp expect.full actual &&
813 git log --oneline --no-decorate >actual &&
814 test_cmp expect.none actual &&
815 git log --oneline --decorate >actual &&
816 test_cmp expect.short actual &&
817
818 test_unconfig log.decorate &&
819 git log --pretty=raw >expect.raw &&
820 test_config log.decorate full &&
821 git log --pretty=raw >actual &&
822 test_cmp expect.raw actual
823
824 '
825
826 test_expect_success 'decorate-refs with glob' '
827 cat >expect.decorate <<-\EOF &&
828 Merge-tag-reach
829 Merge-tags-octopus-a-and-octopus-b
830 seventh
831 octopus-b (octopus-b)
832 octopus-a (octopus-a)
833 reach
834 EOF
835 cat >expect.no-decorate <<-\EOF &&
836 Merge-tag-reach
837 Merge-tags-octopus-a-and-octopus-b
838 seventh
839 octopus-b
840 octopus-a
841 reach
842 EOF
843 git log -n6 --decorate=short --pretty="tformat:%f%d" \
844 --decorate-refs="heads/octopus*" >actual &&
845 test_cmp expect.decorate actual &&
846 git log -n6 --decorate=short --pretty="tformat:%f%d" \
847 --decorate-refs-exclude="heads/octopus*" \
848 --decorate-refs="heads/octopus*" >actual &&
849 test_cmp expect.no-decorate actual &&
850 git -c log.excludeDecoration="heads/octopus*" log \
851 -n6 --decorate=short --pretty="tformat:%f%d" \
852 --decorate-refs="heads/octopus*" >actual &&
853 test_cmp expect.decorate actual
854 '
855
856 test_expect_success 'decorate-refs without globs' '
857 cat >expect.decorate <<-\EOF &&
858 Merge-tag-reach
859 Merge-tags-octopus-a-and-octopus-b
860 seventh
861 octopus-b
862 octopus-a
863 reach (tag: reach)
864 EOF
865 git log -n6 --decorate=short --pretty="tformat:%f%d" \
866 --decorate-refs="tags/reach" >actual &&
867 test_cmp expect.decorate actual
868 '
869
870 test_expect_success 'multiple decorate-refs' '
871 cat >expect.decorate <<-\EOF &&
872 Merge-tag-reach
873 Merge-tags-octopus-a-and-octopus-b
874 seventh
875 octopus-b (octopus-b)
876 octopus-a (octopus-a)
877 reach (tag: reach)
878 EOF
879 git log -n6 --decorate=short --pretty="tformat:%f%d" \
880 --decorate-refs="heads/octopus*" \
881 --decorate-refs="tags/reach" >actual &&
882 test_cmp expect.decorate actual
883 '
884
885 test_expect_success 'decorate-refs-exclude with glob' '
886 cat >expect.decorate <<-\EOF &&
887 Merge-tag-reach (HEAD -> main)
888 Merge-tags-octopus-a-and-octopus-b
889 seventh (tag: seventh)
890 octopus-b (tag: octopus-b)
891 octopus-a (tag: octopus-a)
892 reach (tag: reach, reach)
893 EOF
894 git log -n6 --decorate=short --pretty="tformat:%f%d" \
895 --decorate-refs-exclude="heads/octopus*" >actual &&
896 test_cmp expect.decorate actual &&
897 git -c log.excludeDecoration="heads/octopus*" log \
898 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
899 test_cmp expect.decorate actual
900 '
901
902 test_expect_success 'decorate-refs-exclude without globs' '
903 cat >expect.decorate <<-\EOF &&
904 Merge-tag-reach (HEAD -> main)
905 Merge-tags-octopus-a-and-octopus-b
906 seventh (tag: seventh)
907 octopus-b (tag: octopus-b, octopus-b)
908 octopus-a (tag: octopus-a, octopus-a)
909 reach (reach)
910 EOF
911 git log -n6 --decorate=short --pretty="tformat:%f%d" \
912 --decorate-refs-exclude="tags/reach" >actual &&
913 test_cmp expect.decorate actual &&
914 git -c log.excludeDecoration="tags/reach" log \
915 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
916 test_cmp expect.decorate actual
917 '
918
919 test_expect_success 'multiple decorate-refs-exclude' '
920 cat >expect.decorate <<-\EOF &&
921 Merge-tag-reach (HEAD -> main)
922 Merge-tags-octopus-a-and-octopus-b
923 seventh (tag: seventh)
924 octopus-b (tag: octopus-b)
925 octopus-a (tag: octopus-a)
926 reach (reach)
927 EOF
928 git log -n6 --decorate=short --pretty="tformat:%f%d" \
929 --decorate-refs-exclude="heads/octopus*" \
930 --decorate-refs-exclude="tags/reach" >actual &&
931 test_cmp expect.decorate actual &&
932 git -c log.excludeDecoration="heads/octopus*" \
933 -c log.excludeDecoration="tags/reach" log \
934 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
935 test_cmp expect.decorate actual &&
936 git -c log.excludeDecoration="heads/octopus*" log \
937 --decorate-refs-exclude="tags/reach" \
938 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
939 test_cmp expect.decorate actual
940 '
941
942 test_expect_success 'decorate-refs and decorate-refs-exclude' '
943 cat >expect.no-decorate <<-\EOF &&
944 Merge-tag-reach (main)
945 Merge-tags-octopus-a-and-octopus-b
946 seventh
947 octopus-b
948 octopus-a
949 reach (reach)
950 EOF
951 git log -n6 --decorate=short --pretty="tformat:%f%d" \
952 --decorate-refs="heads/*" \
953 --decorate-refs-exclude="heads/oc*" >actual &&
954 test_cmp expect.no-decorate actual
955 '
956
957 test_expect_success 'deocrate-refs and log.excludeDecoration' '
958 cat >expect.decorate <<-\EOF &&
959 Merge-tag-reach (main)
960 Merge-tags-octopus-a-and-octopus-b
961 seventh
962 octopus-b (octopus-b)
963 octopus-a (octopus-a)
964 reach (reach)
965 EOF
966 git -c log.excludeDecoration="heads/oc*" log \
967 --decorate-refs="heads/*" \
968 -n6 --decorate=short --pretty="tformat:%f%d" >actual &&
969 test_cmp expect.decorate actual
970 '
971
972 test_expect_success 'decorate-refs-exclude and simplify-by-decoration' '
973 cat >expect.decorate <<-\EOF &&
974 Merge-tag-reach (HEAD -> main)
975 reach (tag: reach, reach)
976 seventh (tag: seventh)
977 Merge-branch-tangle
978 Merge-branch-side-early-part-into-tangle (tangle)
979 tangle-a (tag: tangle-a)
980 EOF
981 git log -n6 --decorate=short --pretty="tformat:%f%d" \
982 --decorate-refs-exclude="*octopus*" \
983 --simplify-by-decoration >actual &&
984 test_cmp expect.decorate actual &&
985 git -c log.excludeDecoration="*octopus*" log \
986 -n6 --decorate=short --pretty="tformat:%f%d" \
987 --simplify-by-decoration >actual &&
988 test_cmp expect.decorate actual
989 '
990
991 test_expect_success 'decorate-refs with implied decorate from format' '
992 cat >expect <<-\EOF &&
993 side-2 (tag: side-2)
994 side-1
995 EOF
996 git log --no-walk --format="%s%d" \
997 --decorate-refs="*side-2" side-1 side-2 \
998 >actual &&
999 test_cmp expect actual
1000 '
1001
1002 test_expect_success 'implied decorate does not override option' '
1003 cat >expect <<-\EOF &&
1004 side-2 (tag: refs/tags/side-2, refs/heads/side)
1005 side-1 (tag: refs/tags/side-1)
1006 EOF
1007 git log --no-walk --format="%s%d" \
1008 --decorate=full side-1 side-2 \
1009 >actual &&
1010 test_cmp expect actual
1011 '
1012
1013 test_expect_success 'decorate-refs and simplify-by-decoration without output' '
1014 cat >expect <<-\EOF &&
1015 side-2
1016 initial
1017 EOF
1018 # Do not just use a --format without %d here; we want to
1019 # make sure that we did not accidentally turn on displaying
1020 # the decorations, too. And that requires one of the regular
1021 # formats.
1022 git log --decorate-refs="*side-2" --oneline \
1023 --simplify-by-decoration >actual.raw &&
1024 sed "s/^[0-9a-f]* //" <actual.raw >actual &&
1025 test_cmp expect actual
1026 '
1027
1028 test_expect_success 'log.decorate config parsing' '
1029 git log --oneline --decorate=full >expect.full &&
1030 git log --oneline --decorate=short >expect.short &&
1031
1032 test_config log.decorate full &&
1033 test_config log.mailmap true &&
1034 git log --oneline >actual &&
1035 test_cmp expect.full actual &&
1036 git log --oneline --decorate=short >actual &&
1037 test_cmp expect.short actual
1038 '
1039
1040 test_expect_success TTY 'log output on a TTY' '
1041 git log --color --oneline --decorate >expect.short &&
1042
1043 test_terminal git log --oneline >actual &&
1044 test_cmp expect.short actual
1045 '
1046
1047 test_expect_success 'reflog is expected format' '
1048 git log -g --abbrev-commit --pretty=oneline >expect &&
1049 git reflog >actual &&
1050 test_cmp expect actual
1051 '
1052
1053 test_expect_success 'whatchanged is expected format' '
1054 git log --no-merges --raw >expect &&
1055 git whatchanged >actual &&
1056 test_cmp expect actual
1057 '
1058
1059 test_expect_success 'log.abbrevCommit configuration' '
1060 git log --abbrev-commit >expect.log.abbrev &&
1061 git log --no-abbrev-commit >expect.log.full &&
1062 git log --pretty=raw >expect.log.raw &&
1063 git reflog --abbrev-commit >expect.reflog.abbrev &&
1064 git reflog --no-abbrev-commit >expect.reflog.full &&
1065 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
1066 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
1067
1068 test_config log.abbrevCommit true &&
1069
1070 git log >actual &&
1071 test_cmp expect.log.abbrev actual &&
1072 git log --no-abbrev-commit >actual &&
1073 test_cmp expect.log.full actual &&
1074
1075 git log --pretty=raw >actual &&
1076 test_cmp expect.log.raw actual &&
1077
1078 git reflog >actual &&
1079 test_cmp expect.reflog.abbrev actual &&
1080 git reflog --no-abbrev-commit >actual &&
1081 test_cmp expect.reflog.full actual &&
1082
1083 git whatchanged >actual &&
1084 test_cmp expect.whatchanged.abbrev actual &&
1085 git whatchanged --no-abbrev-commit >actual &&
1086 test_cmp expect.whatchanged.full actual
1087 '
1088
1089 test_expect_success 'show added path under "--follow -M"' '
1090 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
1091 test_create_repo regression &&
1092 (
1093 cd regression &&
1094 test_commit needs-another-commit &&
1095 test_commit foo.bar &&
1096 git log -M --follow -p foo.bar.t &&
1097 git log -M --follow --stat foo.bar.t &&
1098 git log -M --follow --name-only foo.bar.t
1099 )
1100 '
1101
1102 test_expect_success 'git log -c --follow' '
1103 test_create_repo follow-c &&
1104 (
1105 cd follow-c &&
1106 test_commit initial file original &&
1107 git rm file &&
1108 test_commit rename file2 original &&
1109 git reset --hard initial &&
1110 test_commit modify file foo &&
1111 git merge -m merge rename &&
1112 git log -c --follow file2
1113 )
1114 '
1115
1116 cat >expect <<\EOF
1117 * commit COMMIT_OBJECT_NAME
1118 |\ Merge: MERGE_PARENTS
1119 | | Author: A U Thor <author@example.com>
1120 | |
1121 | | Merge HEADS DESCRIPTION
1122 | |
1123 | * commit COMMIT_OBJECT_NAME
1124 | | Author: A U Thor <author@example.com>
1125 | |
1126 | | reach
1127 | | ---
1128 | | reach.t | 1 +
1129 | | 1 file changed, 1 insertion(+)
1130 | |
1131 | | diff --git a/reach.t b/reach.t
1132 | | new file mode 100644
1133 | | index BEFORE..AFTER
1134 | | --- /dev/null
1135 | | +++ b/reach.t
1136 | | @@ -0,0 +1 @@
1137 | | +reach
1138 | |
1139 | \
1140 *-. \ commit COMMIT_OBJECT_NAME
1141 |\ \ \ Merge: MERGE_PARENTS
1142 | | | | Author: A U Thor <author@example.com>
1143 | | | |
1144 | | | | Merge HEADS DESCRIPTION
1145 | | | |
1146 | | * | commit COMMIT_OBJECT_NAME
1147 | | |/ Author: A U Thor <author@example.com>
1148 | | |
1149 | | | octopus-b
1150 | | | ---
1151 | | | octopus-b.t | 1 +
1152 | | | 1 file changed, 1 insertion(+)
1153 | | |
1154 | | | diff --git a/octopus-b.t b/octopus-b.t
1155 | | | new file mode 100644
1156 | | | index BEFORE..AFTER
1157 | | | --- /dev/null
1158 | | | +++ b/octopus-b.t
1159 | | | @@ -0,0 +1 @@
1160 | | | +octopus-b
1161 | | |
1162 | * | commit COMMIT_OBJECT_NAME
1163 | |/ Author: A U Thor <author@example.com>
1164 | |
1165 | | octopus-a
1166 | | ---
1167 | | octopus-a.t | 1 +
1168 | | 1 file changed, 1 insertion(+)
1169 | |
1170 | | diff --git a/octopus-a.t b/octopus-a.t
1171 | | new file mode 100644
1172 | | index BEFORE..AFTER
1173 | | --- /dev/null
1174 | | +++ b/octopus-a.t
1175 | | @@ -0,0 +1 @@
1176 | | +octopus-a
1177 | |
1178 * | commit COMMIT_OBJECT_NAME
1179 |/ Author: A U Thor <author@example.com>
1180 |
1181 | seventh
1182 | ---
1183 | seventh.t | 1 +
1184 | 1 file changed, 1 insertion(+)
1185 |
1186 | diff --git a/seventh.t b/seventh.t
1187 | new file mode 100644
1188 | index BEFORE..AFTER
1189 | --- /dev/null
1190 | +++ b/seventh.t
1191 | @@ -0,0 +1 @@
1192 | +seventh
1193 |
1194 * commit COMMIT_OBJECT_NAME
1195 |\ Merge: MERGE_PARENTS
1196 | | Author: A U Thor <author@example.com>
1197 | |
1198 | | Merge branch 'tangle'
1199 | |
1200 | * commit COMMIT_OBJECT_NAME
1201 | |\ Merge: MERGE_PARENTS
1202 | | | Author: A U Thor <author@example.com>
1203 | | |
1204 | | | Merge branch 'side' (early part) into tangle
1205 | | |
1206 | * | commit COMMIT_OBJECT_NAME
1207 | |\ \ Merge: MERGE_PARENTS
1208 | | | | Author: A U Thor <author@example.com>
1209 | | | |
1210 | | | | Merge branch 'main' (early part) into tangle
1211 | | | |
1212 | * | | commit COMMIT_OBJECT_NAME
1213 | | | | Author: A U Thor <author@example.com>
1214 | | | |
1215 | | | | tangle-a
1216 | | | | ---
1217 | | | | tangle-a | 1 +
1218 | | | | 1 file changed, 1 insertion(+)
1219 | | | |
1220 | | | | diff --git a/tangle-a b/tangle-a
1221 | | | | new file mode 100644
1222 | | | | index BEFORE..AFTER
1223 | | | | --- /dev/null
1224 | | | | +++ b/tangle-a
1225 | | | | @@ -0,0 +1 @@
1226 | | | | +a
1227 | | | |
1228 * | | | commit COMMIT_OBJECT_NAME
1229 |\ \ \ \ Merge: MERGE_PARENTS
1230 | | | | | Author: A U Thor <author@example.com>
1231 | | | | |
1232 | | | | | Merge branch 'side'
1233 | | | | |
1234 | * | | | commit COMMIT_OBJECT_NAME
1235 | | |_|/ Author: A U Thor <author@example.com>
1236 | |/| |
1237 | | | | side-2
1238 | | | | ---
1239 | | | | 2 | 1 +
1240 | | | | 1 file changed, 1 insertion(+)
1241 | | | |
1242 | | | | diff --git a/2 b/2
1243 | | | | new file mode 100644
1244 | | | | index BEFORE..AFTER
1245 | | | | --- /dev/null
1246 | | | | +++ b/2
1247 | | | | @@ -0,0 +1 @@
1248 | | | | +2
1249 | | | |
1250 | * | | commit COMMIT_OBJECT_NAME
1251 | | | | Author: A U Thor <author@example.com>
1252 | | | |
1253 | | | | side-1
1254 | | | | ---
1255 | | | | 1 | 1 +
1256 | | | | 1 file changed, 1 insertion(+)
1257 | | | |
1258 | | | | diff --git a/1 b/1
1259 | | | | new file mode 100644
1260 | | | | index BEFORE..AFTER
1261 | | | | --- /dev/null
1262 | | | | +++ b/1
1263 | | | | @@ -0,0 +1 @@
1264 | | | | +1
1265 | | | |
1266 * | | | commit COMMIT_OBJECT_NAME
1267 | | | | Author: A U Thor <author@example.com>
1268 | | | |
1269 | | | | Second
1270 | | | | ---
1271 | | | | one | 1 +
1272 | | | | 1 file changed, 1 insertion(+)
1273 | | | |
1274 | | | | diff --git a/one b/one
1275 | | | | new file mode 100644
1276 | | | | index BEFORE..AFTER
1277 | | | | --- /dev/null
1278 | | | | +++ b/one
1279 | | | | @@ -0,0 +1 @@
1280 | | | | +case
1281 | | | |
1282 * | | | commit COMMIT_OBJECT_NAME
1283 | |_|/ Author: A U Thor <author@example.com>
1284 |/| |
1285 | | | sixth
1286 | | | ---
1287 | | | a/two | 1 -
1288 | | | 1 file changed, 1 deletion(-)
1289 | | |
1290 | | | diff --git a/a/two b/a/two
1291 | | | deleted file mode 100644
1292 | | | index BEFORE..AFTER
1293 | | | --- a/a/two
1294 | | | +++ /dev/null
1295 | | | @@ -1 +0,0 @@
1296 | | | -ni
1297 | | |
1298 * | | commit COMMIT_OBJECT_NAME
1299 | | | Author: A U Thor <author@example.com>
1300 | | |
1301 | | | fifth
1302 | | | ---
1303 | | | a/two | 1 +
1304 | | | 1 file changed, 1 insertion(+)
1305 | | |
1306 | | | diff --git a/a/two b/a/two
1307 | | | new file mode 100644
1308 | | | index BEFORE..AFTER
1309 | | | --- /dev/null
1310 | | | +++ b/a/two
1311 | | | @@ -0,0 +1 @@
1312 | | | +ni
1313 | | |
1314 * | | commit COMMIT_OBJECT_NAME
1315 |/ / Author: A U Thor <author@example.com>
1316 | |
1317 | | fourth
1318 | | ---
1319 | | ein | 1 +
1320 | | 1 file changed, 1 insertion(+)
1321 | |
1322 | | diff --git a/ein b/ein
1323 | | new file mode 100644
1324 | | index BEFORE..AFTER
1325 | | --- /dev/null
1326 | | +++ b/ein
1327 | | @@ -0,0 +1 @@
1328 | | +ichi
1329 | |
1330 * | commit COMMIT_OBJECT_NAME
1331 |/ Author: A U Thor <author@example.com>
1332 |
1333 | third
1334 | ---
1335 | ichi | 1 +
1336 | one | 1 -
1337 | 2 files changed, 1 insertion(+), 1 deletion(-)
1338 |
1339 | diff --git a/ichi b/ichi
1340 | new file mode 100644
1341 | index BEFORE..AFTER
1342 | --- /dev/null
1343 | +++ b/ichi
1344 | @@ -0,0 +1 @@
1345 | +ichi
1346 | diff --git a/one b/one
1347 | deleted file mode 100644
1348 | index BEFORE..AFTER
1349 | --- a/one
1350 | +++ /dev/null
1351 | @@ -1 +0,0 @@
1352 | -ichi
1353 |
1354 * commit COMMIT_OBJECT_NAME
1355 | Author: A U Thor <author@example.com>
1356 |
1357 | second
1358 | ---
1359 | one | 2 +-
1360 | 1 file changed, 1 insertion(+), 1 deletion(-)
1361 |
1362 | diff --git a/one b/one
1363 | index BEFORE..AFTER 100644
1364 | --- a/one
1365 | +++ b/one
1366 | @@ -1 +1 @@
1367 | -one
1368 | +ichi
1369 |
1370 * commit COMMIT_OBJECT_NAME
1371 Author: A U Thor <author@example.com>
1372
1373 initial
1374 ---
1375 one | 1 +
1376 1 file changed, 1 insertion(+)
1377
1378 diff --git a/one b/one
1379 new file mode 100644
1380 index BEFORE..AFTER
1381 --- /dev/null
1382 +++ b/one
1383 @@ -0,0 +1 @@
1384 +one
1385 EOF
1386
1387 test_expect_success 'log --graph with diff and stats' '
1388 lib_test_cmp_short_graph --no-renames --stat -p
1389 '
1390
1391 cat >expect <<\EOF
1392 *** * commit COMMIT_OBJECT_NAME
1393 *** |\ Merge: MERGE_PARENTS
1394 *** | | Author: A U Thor <author@example.com>
1395 *** | |
1396 *** | | Merge HEADS DESCRIPTION
1397 *** | |
1398 *** | * commit COMMIT_OBJECT_NAME
1399 *** | | Author: A U Thor <author@example.com>
1400 *** | |
1401 *** | | reach
1402 *** | | ---
1403 *** | | reach.t | 1 +
1404 *** | | 1 file changed, 1 insertion(+)
1405 *** | |
1406 *** | | diff --git a/reach.t b/reach.t
1407 *** | | new file mode 100644
1408 *** | | index BEFORE..AFTER
1409 *** | | --- /dev/null
1410 *** | | +++ b/reach.t
1411 *** | | @@ -0,0 +1 @@
1412 *** | | +reach
1413 *** | |
1414 *** | \
1415 *** *-. \ commit COMMIT_OBJECT_NAME
1416 *** |\ \ \ Merge: MERGE_PARENTS
1417 *** | | | | Author: A U Thor <author@example.com>
1418 *** | | | |
1419 *** | | | | Merge HEADS DESCRIPTION
1420 *** | | | |
1421 *** | | * | commit COMMIT_OBJECT_NAME
1422 *** | | |/ Author: A U Thor <author@example.com>
1423 *** | | |
1424 *** | | | octopus-b
1425 *** | | | ---
1426 *** | | | octopus-b.t | 1 +
1427 *** | | | 1 file changed, 1 insertion(+)
1428 *** | | |
1429 *** | | | diff --git a/octopus-b.t b/octopus-b.t
1430 *** | | | new file mode 100644
1431 *** | | | index BEFORE..AFTER
1432 *** | | | --- /dev/null
1433 *** | | | +++ b/octopus-b.t
1434 *** | | | @@ -0,0 +1 @@
1435 *** | | | +octopus-b
1436 *** | | |
1437 *** | * | commit COMMIT_OBJECT_NAME
1438 *** | |/ Author: A U Thor <author@example.com>
1439 *** | |
1440 *** | | octopus-a
1441 *** | | ---
1442 *** | | octopus-a.t | 1 +
1443 *** | | 1 file changed, 1 insertion(+)
1444 *** | |
1445 *** | | diff --git a/octopus-a.t b/octopus-a.t
1446 *** | | new file mode 100644
1447 *** | | index BEFORE..AFTER
1448 *** | | --- /dev/null
1449 *** | | +++ b/octopus-a.t
1450 *** | | @@ -0,0 +1 @@
1451 *** | | +octopus-a
1452 *** | |
1453 *** * | commit COMMIT_OBJECT_NAME
1454 *** |/ Author: A U Thor <author@example.com>
1455 *** |
1456 *** | seventh
1457 *** | ---
1458 *** | seventh.t | 1 +
1459 *** | 1 file changed, 1 insertion(+)
1460 *** |
1461 *** | diff --git a/seventh.t b/seventh.t
1462 *** | new file mode 100644
1463 *** | index BEFORE..AFTER
1464 *** | --- /dev/null
1465 *** | +++ b/seventh.t
1466 *** | @@ -0,0 +1 @@
1467 *** | +seventh
1468 *** |
1469 *** * commit COMMIT_OBJECT_NAME
1470 *** |\ Merge: MERGE_PARENTS
1471 *** | | Author: A U Thor <author@example.com>
1472 *** | |
1473 *** | | Merge branch 'tangle'
1474 *** | |
1475 *** | * commit COMMIT_OBJECT_NAME
1476 *** | |\ Merge: MERGE_PARENTS
1477 *** | | | Author: A U Thor <author@example.com>
1478 *** | | |
1479 *** | | | Merge branch 'side' (early part) into tangle
1480 *** | | |
1481 *** | * | commit COMMIT_OBJECT_NAME
1482 *** | |\ \ Merge: MERGE_PARENTS
1483 *** | | | | Author: A U Thor <author@example.com>
1484 *** | | | |
1485 *** | | | | Merge branch 'main' (early part) into tangle
1486 *** | | | |
1487 *** | * | | commit COMMIT_OBJECT_NAME
1488 *** | | | | Author: A U Thor <author@example.com>
1489 *** | | | |
1490 *** | | | | tangle-a
1491 *** | | | | ---
1492 *** | | | | tangle-a | 1 +
1493 *** | | | | 1 file changed, 1 insertion(+)
1494 *** | | | |
1495 *** | | | | diff --git a/tangle-a b/tangle-a
1496 *** | | | | new file mode 100644
1497 *** | | | | index BEFORE..AFTER
1498 *** | | | | --- /dev/null
1499 *** | | | | +++ b/tangle-a
1500 *** | | | | @@ -0,0 +1 @@
1501 *** | | | | +a
1502 *** | | | |
1503 *** * | | | commit COMMIT_OBJECT_NAME
1504 *** |\ \ \ \ Merge: MERGE_PARENTS
1505 *** | | | | | Author: A U Thor <author@example.com>
1506 *** | | | | |
1507 *** | | | | | Merge branch 'side'
1508 *** | | | | |
1509 *** | * | | | commit COMMIT_OBJECT_NAME
1510 *** | | |_|/ Author: A U Thor <author@example.com>
1511 *** | |/| |
1512 *** | | | | side-2
1513 *** | | | | ---
1514 *** | | | | 2 | 1 +
1515 *** | | | | 1 file changed, 1 insertion(+)
1516 *** | | | |
1517 *** | | | | diff --git a/2 b/2
1518 *** | | | | new file mode 100644
1519 *** | | | | index BEFORE..AFTER
1520 *** | | | | --- /dev/null
1521 *** | | | | +++ b/2
1522 *** | | | | @@ -0,0 +1 @@
1523 *** | | | | +2
1524 *** | | | |
1525 *** | * | | commit COMMIT_OBJECT_NAME
1526 *** | | | | Author: A U Thor <author@example.com>
1527 *** | | | |
1528 *** | | | | side-1
1529 *** | | | | ---
1530 *** | | | | 1 | 1 +
1531 *** | | | | 1 file changed, 1 insertion(+)
1532 *** | | | |
1533 *** | | | | diff --git a/1 b/1
1534 *** | | | | new file mode 100644
1535 *** | | | | index BEFORE..AFTER
1536 *** | | | | --- /dev/null
1537 *** | | | | +++ b/1
1538 *** | | | | @@ -0,0 +1 @@
1539 *** | | | | +1
1540 *** | | | |
1541 *** * | | | commit COMMIT_OBJECT_NAME
1542 *** | | | | Author: A U Thor <author@example.com>
1543 *** | | | |
1544 *** | | | | Second
1545 *** | | | | ---
1546 *** | | | | one | 1 +
1547 *** | | | | 1 file changed, 1 insertion(+)
1548 *** | | | |
1549 *** | | | | diff --git a/one b/one
1550 *** | | | | new file mode 100644
1551 *** | | | | index BEFORE..AFTER
1552 *** | | | | --- /dev/null
1553 *** | | | | +++ b/one
1554 *** | | | | @@ -0,0 +1 @@
1555 *** | | | | +case
1556 *** | | | |
1557 *** * | | | commit COMMIT_OBJECT_NAME
1558 *** | |_|/ Author: A U Thor <author@example.com>
1559 *** |/| |
1560 *** | | | sixth
1561 *** | | | ---
1562 *** | | | a/two | 1 -
1563 *** | | | 1 file changed, 1 deletion(-)
1564 *** | | |
1565 *** | | | diff --git a/a/two b/a/two
1566 *** | | | deleted file mode 100644
1567 *** | | | index BEFORE..AFTER
1568 *** | | | --- a/a/two
1569 *** | | | +++ /dev/null
1570 *** | | | @@ -1 +0,0 @@
1571 *** | | | -ni
1572 *** | | |
1573 *** * | | commit COMMIT_OBJECT_NAME
1574 *** | | | Author: A U Thor <author@example.com>
1575 *** | | |
1576 *** | | | fifth
1577 *** | | | ---
1578 *** | | | a/two | 1 +
1579 *** | | | 1 file changed, 1 insertion(+)
1580 *** | | |
1581 *** | | | diff --git a/a/two b/a/two
1582 *** | | | new file mode 100644
1583 *** | | | index BEFORE..AFTER
1584 *** | | | --- /dev/null
1585 *** | | | +++ b/a/two
1586 *** | | | @@ -0,0 +1 @@
1587 *** | | | +ni
1588 *** | | |
1589 *** * | | commit COMMIT_OBJECT_NAME
1590 *** |/ / Author: A U Thor <author@example.com>
1591 *** | |
1592 *** | | fourth
1593 *** | | ---
1594 *** | | ein | 1 +
1595 *** | | 1 file changed, 1 insertion(+)
1596 *** | |
1597 *** | | diff --git a/ein b/ein
1598 *** | | new file mode 100644
1599 *** | | index BEFORE..AFTER
1600 *** | | --- /dev/null
1601 *** | | +++ b/ein
1602 *** | | @@ -0,0 +1 @@
1603 *** | | +ichi
1604 *** | |
1605 *** * | commit COMMIT_OBJECT_NAME
1606 *** |/ Author: A U Thor <author@example.com>
1607 *** |
1608 *** | third
1609 *** | ---
1610 *** | ichi | 1 +
1611 *** | one | 1 -
1612 *** | 2 files changed, 1 insertion(+), 1 deletion(-)
1613 *** |
1614 *** | diff --git a/ichi b/ichi
1615 *** | new file mode 100644
1616 *** | index BEFORE..AFTER
1617 *** | --- /dev/null
1618 *** | +++ b/ichi
1619 *** | @@ -0,0 +1 @@
1620 *** | +ichi
1621 *** | diff --git a/one b/one
1622 *** | deleted file mode 100644
1623 *** | index BEFORE..AFTER
1624 *** | --- a/one
1625 *** | +++ /dev/null
1626 *** | @@ -1 +0,0 @@
1627 *** | -ichi
1628 *** |
1629 *** * commit COMMIT_OBJECT_NAME
1630 *** | Author: A U Thor <author@example.com>
1631 *** |
1632 *** | second
1633 *** | ---
1634 *** | one | 2 +-
1635 *** | 1 file changed, 1 insertion(+), 1 deletion(-)
1636 *** |
1637 *** | diff --git a/one b/one
1638 *** | index BEFORE..AFTER 100644
1639 *** | --- a/one
1640 *** | +++ b/one
1641 *** | @@ -1 +1 @@
1642 *** | -one
1643 *** | +ichi
1644 *** |
1645 *** * commit COMMIT_OBJECT_NAME
1646 *** Author: A U Thor <author@example.com>
1647 ***
1648 *** initial
1649 *** ---
1650 *** one | 1 +
1651 *** 1 file changed, 1 insertion(+)
1652 ***
1653 *** diff --git a/one b/one
1654 *** new file mode 100644
1655 *** index BEFORE..AFTER
1656 *** --- /dev/null
1657 *** +++ b/one
1658 *** @@ -0,0 +1 @@
1659 *** +one
1660 EOF
1661
1662 test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1663 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1664 '
1665
1666 cat >expect <<-\EOF
1667 * reach
1668 |
1669 | A reach.t
1670 * Merge branch 'tangle'
1671 * Merge branch 'side'
1672 |\
1673 | * side-2
1674 |
1675 | A 2
1676 * Second
1677 |
1678 | A one
1679 * sixth
1680
1681 D a/two
1682 EOF
1683
1684 test_expect_success 'log --graph with --name-status' '
1685 test_cmp_graph --name-status tangle..reach
1686 '
1687
1688 cat >expect <<-\EOF
1689 * reach
1690 |
1691 | reach.t
1692 * Merge branch 'tangle'
1693 * Merge branch 'side'
1694 |\
1695 | * side-2
1696 |
1697 | 2
1698 * Second
1699 |
1700 | one
1701 * sixth
1702
1703 a/two
1704 EOF
1705
1706 test_expect_success 'log --graph with --name-only' '
1707 test_cmp_graph --name-only tangle..reach
1708 '
1709
1710 test_expect_success '--no-graph countermands --graph' '
1711 git log >expect &&
1712 git log --graph --no-graph >actual &&
1713 test_cmp expect actual
1714 '
1715
1716 test_expect_success '--graph countermands --no-graph' '
1717 git log --graph >expect &&
1718 git log --no-graph --graph >actual &&
1719 test_cmp expect actual
1720 '
1721
1722 test_expect_success '--no-graph does not unset --topo-order' '
1723 git log --topo-order >expect &&
1724 git log --topo-order --no-graph >actual &&
1725 test_cmp expect actual
1726 '
1727
1728 test_expect_success '--no-graph does not unset --parents' '
1729 git log --parents >expect &&
1730 git log --parents --no-graph >actual &&
1731 test_cmp expect actual
1732 '
1733
1734 test_expect_success '--reverse and --graph conflict' '
1735 test_must_fail git log --reverse --graph 2>stderr &&
1736 test_i18ngrep "cannot be used together" stderr
1737 '
1738
1739 test_expect_success '--reverse --graph --no-graph works' '
1740 git log --reverse >expect &&
1741 git log --reverse --graph --no-graph >actual &&
1742 test_cmp expect actual
1743 '
1744
1745 test_expect_success '--show-linear-break and --graph conflict' '
1746 test_must_fail git log --show-linear-break --graph 2>stderr &&
1747 test_i18ngrep "cannot be used together" stderr
1748 '
1749
1750 test_expect_success '--show-linear-break --graph --no-graph works' '
1751 git log --show-linear-break >expect &&
1752 git log --show-linear-break --graph --no-graph >actual &&
1753 test_cmp expect actual
1754 '
1755
1756 test_expect_success '--no-walk and --graph conflict' '
1757 test_must_fail git log --no-walk --graph 2>stderr &&
1758 test_i18ngrep "cannot be used together" stderr
1759 '
1760
1761 test_expect_success '--no-walk --graph --no-graph works' '
1762 git log --no-walk >expect &&
1763 git log --no-walk --graph --no-graph >actual &&
1764 test_cmp expect actual
1765 '
1766
1767 test_expect_success '--walk-reflogs and --graph conflict' '
1768 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1769 (test_i18ngrep "cannot combine" stderr ||
1770 test_i18ngrep "cannot be used together" stderr)
1771 '
1772
1773 test_expect_success '--walk-reflogs --graph --no-graph works' '
1774 git log --walk-reflogs >expect &&
1775 git log --walk-reflogs --graph --no-graph >actual &&
1776 test_cmp expect actual
1777 '
1778
1779 test_expect_success 'dotdot is a parent directory' '
1780 mkdir -p a/b &&
1781 ( echo sixth && echo fifth ) >expect &&
1782 ( cd a/b && git log --format=%s .. ) >actual &&
1783 test_cmp expect actual
1784 '
1785
1786 test_expect_success GPG 'setup signed branch' '
1787 test_when_finished "git reset --hard && git checkout main" &&
1788 git checkout -b signed main &&
1789 echo foo >foo &&
1790 git add foo &&
1791 git commit -S -m signed_commit
1792 '
1793
1794 test_expect_success GPG 'setup signed branch with subkey' '
1795 test_when_finished "git reset --hard && git checkout main" &&
1796 git checkout -b signed-subkey main &&
1797 echo foo >foo &&
1798 git add foo &&
1799 git commit -SB7227189 -m signed_commit
1800 '
1801
1802 test_expect_success GPGSM 'setup signed branch x509' '
1803 test_when_finished "git reset --hard && git checkout main" &&
1804 git checkout -b signed-x509 main &&
1805 echo foo >foo &&
1806 git add foo &&
1807 test_config gpg.format x509 &&
1808 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
1809 git commit -S -m signed_commit
1810 '
1811
1812 test_expect_success GPGSSH 'setup sshkey signed branch' '
1813 test_config gpg.format ssh &&
1814 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
1815 test_when_finished "git reset --hard && git checkout main" &&
1816 git checkout -b signed-ssh main &&
1817 echo foo >foo &&
1818 git add foo &&
1819 git commit -S -m signed_commit
1820 '
1821
1822 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
1823 test_config gpg.format ssh &&
1824 touch file &&
1825 git add file &&
1826
1827 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
1828 git tag expired-signed &&
1829
1830 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
1831 git tag notyetvalid-signed &&
1832
1833 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
1834 git tag timeboxedvalid-signed &&
1835
1836 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
1837 git tag timeboxedinvalid-signed
1838 '
1839
1840 test_expect_success GPGSM 'log x509 fingerprint' '
1841 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
1842 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
1843 test_cmp expect actual
1844 '
1845
1846 test_expect_success GPGSM 'log OpenPGP fingerprint' '
1847 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
1848 git log -n1 --format="%GP" signed-subkey >actual &&
1849 test_cmp expect actual
1850 '
1851
1852 test_expect_success GPGSSH 'log ssh key fingerprint' '
1853 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1854 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
1855 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
1856 test_cmp expect actual
1857 '
1858
1859 test_expect_success GPG 'log --graph --show-signature' '
1860 git log --graph --show-signature -n1 signed >actual &&
1861 grep "^| gpg: Signature made" actual &&
1862 grep "^| gpg: Good signature" actual
1863 '
1864
1865 test_expect_success GPGSM 'log --graph --show-signature x509' '
1866 git log --graph --show-signature -n1 signed-x509 >actual &&
1867 grep "^| gpgsm: Signature made" actual &&
1868 grep "^| gpgsm: Good signature" actual
1869 '
1870
1871 test_expect_success GPGSSH 'log --graph --show-signature ssh' '
1872 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1873 git log --graph --show-signature -n1 signed-ssh >actual &&
1874 grep "${GOOD_SIGNATURE_TRUSTED}" actual
1875 '
1876
1877 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
1878 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1879 git log --graph --show-signature -n1 expired-signed >actual &&
1880 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1881 '
1882
1883 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
1884 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1885 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
1886 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1887 '
1888
1889 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
1890 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1891 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
1892 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
1893 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
1894 '
1895
1896 test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
1897 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
1898 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
1899 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
1900 '
1901
1902 test_expect_success GPG 'log --graph --show-signature for merged tag' '
1903 test_when_finished "git reset --hard && git checkout main" &&
1904 git checkout -b plain main &&
1905 echo aaa >bar &&
1906 git add bar &&
1907 git commit -m bar_commit &&
1908 git checkout -b tagged main &&
1909 echo bbb >baz &&
1910 git add baz &&
1911 git commit -m baz_commit &&
1912 git tag -s -m signed_tag_msg signed_tag &&
1913 git checkout plain &&
1914 git merge --no-ff -m msg signed_tag &&
1915 git log --graph --show-signature -n1 plain >actual &&
1916 grep "^|\\\ merged tag" actual &&
1917 grep "^| | gpg: Signature made" actual &&
1918 grep "^| | gpg: Good signature" actual
1919 '
1920
1921 test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
1922 test_when_finished "git reset --hard && git checkout main" &&
1923 git checkout -b plain-shallow main &&
1924 echo aaa >bar &&
1925 git add bar &&
1926 git commit -m bar_commit &&
1927 git checkout --detach main &&
1928 echo bbb >baz &&
1929 git add baz &&
1930 git commit -m baz_commit &&
1931 git tag -s -m signed_tag_msg signed_tag_shallow &&
1932 hash=$(git rev-parse HEAD) &&
1933 git checkout plain-shallow &&
1934 git merge --no-ff -m msg signed_tag_shallow &&
1935 git clone --depth 1 --no-local . shallow &&
1936 test_when_finished "rm -rf shallow" &&
1937 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
1938 grep "tag signed_tag_shallow names a non-parent $hash" actual
1939 '
1940
1941 test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
1942 test_when_finished "git reset --hard && git checkout main" &&
1943 git checkout -b plain-nokey main &&
1944 echo aaa >bar &&
1945 git add bar &&
1946 git commit -m bar_commit &&
1947 git checkout -b tagged-nokey main &&
1948 echo bbb >baz &&
1949 git add baz &&
1950 git commit -m baz_commit &&
1951 git tag -s -m signed_tag_msg signed_tag_nokey &&
1952 git checkout plain-nokey &&
1953 git merge --no-ff -m msg signed_tag_nokey &&
1954 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
1955 grep "^|\\\ merged tag" actual &&
1956 grep "^| | gpg: Signature made" actual &&
1957 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
1958 '
1959
1960 test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
1961 test_when_finished "git reset --hard && git checkout main" &&
1962 git checkout -b plain-bad main &&
1963 echo aaa >bar &&
1964 git add bar &&
1965 git commit -m bar_commit &&
1966 git checkout -b tagged-bad main &&
1967 echo bbb >baz &&
1968 git add baz &&
1969 git commit -m baz_commit &&
1970 git tag -s -m signed_tag_msg signed_tag_bad &&
1971 git cat-file tag signed_tag_bad >raw &&
1972 sed -e "s/signed_tag_msg/forged/" raw >forged &&
1973 git hash-object -w -t tag forged >forged.tag &&
1974 git checkout plain-bad &&
1975 git merge --no-ff -m msg "$(cat forged.tag)" &&
1976 git log --graph --show-signature -n1 plain-bad >actual &&
1977 grep "^|\\\ merged tag" actual &&
1978 grep "^| | gpg: Signature made" actual &&
1979 grep "^| | gpg: BAD signature from" actual
1980 '
1981
1982 test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
1983 test_when_finished "git reset --hard && git checkout main" &&
1984 git checkout -b plain-fail main &&
1985 echo aaa >bar &&
1986 git add bar &&
1987 git commit -m bar_commit &&
1988 git checkout -b tagged-fail main &&
1989 echo bbb >baz &&
1990 git add baz &&
1991 git commit -m baz_commit &&
1992 git tag -s -m signed_tag_msg signed_tag_fail &&
1993 git checkout plain-fail &&
1994 git merge --no-ff -m msg signed_tag_fail &&
1995 if ! test_have_prereq VALGRIND
1996 then
1997 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
1998 grep "^merged tag" actual &&
1999 grep "^No signature" actual &&
2000 ! grep "^gpg: Signature made" actual
2001 fi
2002 '
2003
2004 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2005 test_when_finished "git reset --hard && git checkout main" &&
2006 test_config gpg.format x509 &&
2007 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2008 git checkout -b plain-x509 main &&
2009 echo aaa >bar &&
2010 git add bar &&
2011 git commit -m bar_commit &&
2012 git checkout -b tagged-x509 main &&
2013 echo bbb >baz &&
2014 git add baz &&
2015 git commit -m baz_commit &&
2016 git tag -s -m signed_tag_msg signed_tag_x509 &&
2017 git checkout plain-x509 &&
2018 git merge --no-ff -m msg signed_tag_x509 &&
2019 git log --graph --show-signature -n1 plain-x509 >actual &&
2020 grep "^|\\\ merged tag" actual &&
2021 grep "^| | gpgsm: Signature made" actual &&
2022 grep "^| | gpgsm: Good signature" actual
2023 '
2024
2025 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2026 test_when_finished "git reset --hard && git checkout main" &&
2027 test_config gpg.format x509 &&
2028 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2029 git checkout -b plain-x509-nokey main &&
2030 echo aaa >bar &&
2031 git add bar &&
2032 git commit -m bar_commit &&
2033 git checkout -b tagged-x509-nokey main &&
2034 echo bbb >baz &&
2035 git add baz &&
2036 git commit -m baz_commit &&
2037 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2038 git checkout plain-x509-nokey &&
2039 git merge --no-ff -m msg signed_tag_x509_nokey &&
2040 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2041 grep "^|\\\ merged tag" actual &&
2042 grep -e "^| | gpgsm: certificate not found" \
2043 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2044 '
2045
2046 test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2047 test_when_finished "git reset --hard && git checkout main" &&
2048 test_config gpg.format x509 &&
2049 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2050 git checkout -b plain-x509-bad main &&
2051 echo aaa >bar &&
2052 git add bar &&
2053 git commit -m bar_commit &&
2054 git checkout -b tagged-x509-bad main &&
2055 echo bbb >baz &&
2056 git add baz &&
2057 git commit -m baz_commit &&
2058 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2059 git cat-file tag signed_tag_x509_bad >raw &&
2060 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2061 git hash-object -w -t tag forged >forged.tag &&
2062 git checkout plain-x509-bad &&
2063 git merge --no-ff -m msg "$(cat forged.tag)" &&
2064 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2065 grep "^|\\\ merged tag" actual &&
2066 grep "^| | gpgsm: Signature made" actual &&
2067 grep "^| | gpgsm: invalid signature" actual
2068 '
2069
2070
2071 test_expect_success GPG '--no-show-signature overrides --show-signature' '
2072 git log -1 --show-signature --no-show-signature signed >actual &&
2073 ! grep "^gpg:" actual
2074 '
2075
2076 test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2077 test_config log.showsignature true &&
2078 git log -1 signed >actual &&
2079 grep "gpg: Signature made" actual &&
2080 grep "gpg: Good signature" actual
2081 '
2082
2083 test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2084 test_config log.showsignature true &&
2085 git log -1 --no-show-signature signed >actual &&
2086 ! grep "^gpg:" actual
2087 '
2088
2089 test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2090 test_config log.showsignature false &&
2091 git log -1 --show-signature signed >actual &&
2092 grep "gpg: Signature made" actual &&
2093 grep "gpg: Good signature" actual
2094 '
2095
2096 test_expect_success 'log --graph --no-walk is forbidden' '
2097 test_must_fail git log --graph --no-walk
2098 '
2099
2100 test_expect_success 'log on empty repo fails' '
2101 git init empty &&
2102 test_when_finished "rm -rf empty" &&
2103 test_must_fail git -C empty log 2>stderr &&
2104 test_i18ngrep does.not.have.any.commits stderr
2105 '
2106
2107 test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
2108 git init empty &&
2109 test_when_finished "rm -rf empty" &&
2110 echo 1234abcd >empty/.git/refs/heads/main &&
2111 test_must_fail git -C empty log 2>stderr &&
2112 test_i18ngrep broken stderr
2113 '
2114
2115 test_expect_success 'log diagnoses bogus HEAD symref' '
2116 git init empty &&
2117 git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
2118 test_must_fail git -C empty log 2>stderr &&
2119 test_i18ngrep broken stderr &&
2120 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
2121 test_i18ngrep broken stderr
2122 '
2123
2124 test_expect_success 'log does not default to HEAD when rev input is given' '
2125 git log --branches=does-not-exist >actual &&
2126 test_must_be_empty actual
2127 '
2128
2129 test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2130 git log --ignore-missing $ZERO_OID >actual &&
2131 test_must_be_empty actual
2132 '
2133
2134 test_expect_success 'do not default to HEAD with ignored object on stdin' '
2135 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2136 test_must_be_empty actual
2137 '
2138
2139 test_expect_success 'set up --source tests' '
2140 git checkout --orphan source-a &&
2141 test_commit one &&
2142 test_commit two &&
2143 git checkout -b source-b HEAD^ &&
2144 test_commit three
2145 '
2146
2147 test_expect_success 'log --source paints branch names' '
2148 cat >expect <<-EOF &&
2149 $(git rev-parse --short :/three) source-b three
2150 $(git rev-parse --short :/two ) source-a two
2151 $(git rev-parse --short :/one ) source-b one
2152 EOF
2153 git log --oneline --source source-a source-b >actual &&
2154 test_cmp expect actual
2155 '
2156
2157 test_expect_success 'log --source paints tag names' '
2158 git tag -m tagged source-tag &&
2159 cat >expect <<-EOF &&
2160 $(git rev-parse --short :/three) source-tag three
2161 $(git rev-parse --short :/two ) source-a two
2162 $(git rev-parse --short :/one ) source-tag one
2163 EOF
2164 git log --oneline --source source-tag source-a >actual &&
2165 test_cmp expect actual
2166 '
2167
2168 test_expect_success 'log --source paints symmetric ranges' '
2169 cat >expect <<-EOF &&
2170 $(git rev-parse --short :/three) source-b three
2171 $(git rev-parse --short :/two ) source-a two
2172 EOF
2173 git log --oneline --source source-a...source-b >actual &&
2174 test_cmp expect actual
2175 '
2176
2177 test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2178 test_must_fail git log --exclude-promisor-objects source-a
2179 '
2180
2181 test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2182 git checkout -b branch &&
2183 git commit --allow-empty -m "new commit" &&
2184 git tag lightweight HEAD &&
2185 git tag -m annotated annotated HEAD &&
2186 git tag -m double-0 double-0 HEAD &&
2187 git tag -m double-1 double-1 double-0 &&
2188 cat >expect <<-\EOF &&
2189 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
2190 EOF
2191 git log -1 --format="%D" >actual &&
2192 test_cmp expect actual
2193 '
2194
2195 test_expect_success 'log --end-of-options' '
2196 git update-ref refs/heads/--source HEAD &&
2197 git log --end-of-options --source >actual &&
2198 git log >expect &&
2199 test_cmp expect actual
2200 '
2201
2202 test_expect_success 'set up commits with different authors' '
2203 git checkout --orphan authors &&
2204 test_commit --author "Jim <jim@example.com>" jim_1 &&
2205 test_commit --author "Val <val@example.com>" val_1 &&
2206 test_commit --author "Val <val@example.com>" val_2 &&
2207 test_commit --author "Jim <jim@example.com>" jim_2 &&
2208 test_commit --author "Val <val@example.com>" val_3 &&
2209 test_commit --author "Jim <jim@example.com>" jim_3
2210 '
2211
2212 test_expect_success 'log --invert-grep --grep --author' '
2213 cat >expect <<-\EOF &&
2214 val_3
2215 val_1
2216 EOF
2217 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2218 test_cmp expect actual
2219 '
2220
2221 test_done