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