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