Git fork
1#!/bin/sh
2
3test_description='git log'
4
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6export 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
13test_cmp_graph () {
14 lib_test_cmp_graph --format=%s "$@"
15}
16
17test_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
50printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
51test_expect_success 'pretty' '
52
53 git log --pretty="format:%s" > actual &&
54 test_cmp expect actual
55'
56
57printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
58test_expect_success 'pretty (tformat)' '
59
60 git log --pretty="tformat:%s" > actual &&
61 test_cmp expect actual
62'
63
64test_expect_success 'pretty (shortcut)' '
65
66 git log --pretty="%s" > actual &&
67 test_cmp expect actual
68'
69
70test_expect_success 'format' '
71
72 git log --format="%s" > actual &&
73 test_cmp expect actual
74'
75
76cat > expect << EOF
77 This is
78 the sixth
79 commit.
80 This is
81 the fifth
82 commit.
83EOF
84
85test_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
91test_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
97cat > 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
104EOF
105test_expect_success 'oneline' '
106
107 git log --oneline > actual &&
108 test_cmp expect actual
109'
110
111test_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
121test_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
129test_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
137test_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
143test_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
151test_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
164test_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
172test_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
179test_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
186test_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
191test_expect_success 'git config log.follow does not die with no paths' '
192 test_config log.follow true &&
193 git log --
194'
195
196test_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
204test_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
211test_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.
219last_three="$(git rev-parse :/fourth :/sixth :/fifth)"
220cat > expect << EOF
221$(git rev-parse --short :/sixth ) sixth
222$(git rev-parse --short :/fifth ) fifth
223$(git rev-parse --short :/fourth) fourth
224EOF
225test_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
230test_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
235cat > expect << EOF
236=== $(git rev-parse --short :/sixth ) sixth
237=== $(git rev-parse --short :/fifth ) fifth
238=== $(git rev-parse --short :/fourth) fourth
239EOF
240test_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
245cat > expect << EOF
246$(git rev-parse --short :/fourth) fourth
247$(git rev-parse --short :/sixth ) sixth
248$(git rev-parse --short :/fifth ) fifth
249EOF
250test_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
255test_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
260test_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
267test_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
273for noop_opt in --invert-grep --all-match
274do
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 '
280done
281
282cat > expect << EOF
283second
284initial
285EOF
286test_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
307test_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
330test_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
337test_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
343test_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
366test_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
373test_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
395test_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
401test_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
408test_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
495cmds="show reflog format-patch"
496if test_have_prereq !WITH_BREAKING_CHANGES
497then
498 cmds="$cmds whatchanged"
499fi
500for cmd in $cmds
501do
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 '
522done
523
524test_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
534test_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
544test_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
555test_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
565test_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
575cat > expect <<EOF
576* Second
577* sixth
578* fifth
579* fourth
580* third
581* second
582* initial
583EOF
584
585test_expect_success 'simple log --graph' '
586 test_cmp_graph
587'
588
589cat > expect <<EOF
590123 * Second
591123 * sixth
592123 * fifth
593123 * fourth
594123 * third
595123 * second
596123 * initial
597EOF
598
599test_expect_success 'simple log --graph --line-prefix="123 "' '
600 test_cmp_graph --line-prefix="123 "
601'
602
603test_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
611cat > 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
624EOF
625
626test_expect_success 'log --graph with merge' '
627 test_cmp_graph --date-order
628'
629
630cat > 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
643EOF
644
645test_expect_success 'log --graph --line-prefix="| | | " with merge' '
646 test_cmp_graph --line-prefix="| | | " --date-order
647'
648
649cat > 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
662EOF
663
664test_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
669test_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
674test_expect_success 'diff-tree --graph' '
675 git diff-tree --graph main^ | head -n 500 >actual &&
676 grep "one" actual
677'
678
679cat > 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
730EOF
731
732test_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
739test_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
763cat > 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
802EOF
803
804test_expect_success 'log --graph with merge' '
805 test_cmp_graph --date-order
806'
807
808test_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
865test_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
880test_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
910test_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
924test_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
939test_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
956test_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
973test_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
996test_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
1011test_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
1026test_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
1045test_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
1056test_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
1067test_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
1082test_expect_success 'decorate-refs-exclude HEAD' '
1083 git log --decorate=full --oneline \
1084 --decorate-refs-exclude="HEAD" >actual &&
1085 ! grep HEAD actual
1086'
1087
1088test_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
1094test_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
1150test_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
1191test_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
1203test_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
1210test_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
1216test_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
1223test_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
1262test_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
1268test_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
1274test_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
1280test_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
1286test_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
1299test_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
1313cat >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
1582EOF
1583
1584test_expect_success 'log --graph with diff and stats' '
1585 lib_test_cmp_short_graph --no-renames --stat -p
1586'
1587
1588cat >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
1857EOF
1858
1859test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1860 lib_test_cmp_short_graph --line-prefix="*** " --no-renames --stat -p
1861'
1862
1863cat >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
1879EOF
1880
1881test_expect_success 'log --graph with --name-status' '
1882 test_cmp_graph --name-status tangle..reach
1883'
1884
1885cat >expect <<-\EOF
1886* reach
1887|
1888| reach.t
1889* Merge branch 'tangle'
1890* Merge branch 'side'
1891|\
1892| * side-2
1893|
1894| 2
1895* Second
1896|
1897| one
1898* sixth
1899
1900 a/two
1901EOF
1902
1903test_expect_success 'log --graph with --name-only' '
1904 test_cmp_graph --name-only tangle..reach
1905'
1906
1907test_expect_success '--no-graph countermands --graph' '
1908 git log >expect &&
1909 git log --graph --no-graph >actual &&
1910 test_cmp expect actual
1911'
1912
1913test_expect_success '--graph countermands --no-graph' '
1914 git log --graph >expect &&
1915 git log --no-graph --graph >actual &&
1916 test_cmp expect actual
1917'
1918
1919test_expect_success '--no-graph does not unset --topo-order' '
1920 git log --topo-order >expect &&
1921 git log --topo-order --no-graph >actual &&
1922 test_cmp expect actual
1923'
1924
1925test_expect_success '--no-graph does not unset --parents' '
1926 git log --parents >expect &&
1927 git log --parents --no-graph >actual &&
1928 test_cmp expect actual
1929'
1930
1931test_expect_success '--reverse and --graph conflict' '
1932 test_must_fail git log --reverse --graph 2>stderr &&
1933 test_grep "cannot be used together" stderr
1934'
1935
1936test_expect_success '--reverse --graph --no-graph works' '
1937 git log --reverse >expect &&
1938 git log --reverse --graph --no-graph >actual &&
1939 test_cmp expect actual
1940'
1941
1942test_expect_success '--show-linear-break and --graph conflict' '
1943 test_must_fail git log --show-linear-break --graph 2>stderr &&
1944 test_grep "cannot be used together" stderr
1945'
1946
1947test_expect_success '--show-linear-break --graph --no-graph works' '
1948 git log --show-linear-break >expect &&
1949 git log --show-linear-break --graph --no-graph >actual &&
1950 test_cmp expect actual
1951'
1952
1953test_expect_success '--no-walk and --graph conflict' '
1954 test_must_fail git log --no-walk --graph 2>stderr &&
1955 test_grep "cannot be used together" stderr
1956'
1957
1958test_expect_success '--no-walk --graph --no-graph works' '
1959 git log --no-walk >expect &&
1960 git log --no-walk --graph --no-graph >actual &&
1961 test_cmp expect actual
1962'
1963
1964test_expect_success '--walk-reflogs and --graph conflict' '
1965 test_must_fail git log --walk-reflogs --graph 2>stderr &&
1966 (test_grep "cannot combine" stderr ||
1967 test_grep "cannot be used together" stderr)
1968'
1969
1970test_expect_success '--walk-reflogs --graph --no-graph works' '
1971 git log --walk-reflogs >expect &&
1972 git log --walk-reflogs --graph --no-graph >actual &&
1973 test_cmp expect actual
1974'
1975
1976test_expect_success 'dotdot is a parent directory' '
1977 mkdir -p a/b &&
1978 ( echo sixth && echo fifth ) >expect &&
1979 ( cd a/b && git log --format=%s .. ) >actual &&
1980 test_cmp expect actual
1981'
1982
1983test_expect_success GPG 'setup signed branch' '
1984 test_when_finished "git reset --hard && git checkout main" &&
1985 git checkout -b signed main &&
1986 echo foo >foo &&
1987 git add foo &&
1988 git commit -S -m signed_commit
1989'
1990
1991test_expect_success GPG 'setup signed branch with subkey' '
1992 test_when_finished "git reset --hard && git checkout main" &&
1993 git checkout -b signed-subkey main &&
1994 echo foo >foo &&
1995 git add foo &&
1996 git commit -SB7227189 -m signed_commit
1997'
1998
1999test_expect_success GPGSM 'setup signed branch x509' '
2000 test_when_finished "git reset --hard && git checkout main" &&
2001 git checkout -b signed-x509 main &&
2002 echo foo >foo &&
2003 git add foo &&
2004 test_config gpg.format x509 &&
2005 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2006 git commit -S -m signed_commit
2007'
2008
2009test_expect_success GPGSSH 'setup sshkey signed branch' '
2010 test_config gpg.format ssh &&
2011 test_config user.signingkey "${GPGSSH_KEY_PRIMARY}" &&
2012 test_when_finished "git reset --hard && git checkout main" &&
2013 git checkout -b signed-ssh main &&
2014 echo foo >foo &&
2015 git add foo &&
2016 git commit -S -m signed_commit
2017'
2018
2019test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'create signed commits with keys having defined lifetimes' '
2020 test_config gpg.format ssh &&
2021 touch file &&
2022 git add file &&
2023
2024 echo expired >file && test_tick && git commit -a -m expired -S"${GPGSSH_KEY_EXPIRED}" &&
2025 git tag expired-signed &&
2026
2027 echo notyetvalid >file && test_tick && git commit -a -m notyetvalid -S"${GPGSSH_KEY_NOTYETVALID}" &&
2028 git tag notyetvalid-signed &&
2029
2030 echo timeboxedvalid >file && test_tick && git commit -a -m timeboxedvalid -S"${GPGSSH_KEY_TIMEBOXEDVALID}" &&
2031 git tag timeboxedvalid-signed &&
2032
2033 echo timeboxedinvalid >file && test_tick && git commit -a -m timeboxedinvalid -S"${GPGSSH_KEY_TIMEBOXEDINVALID}" &&
2034 git tag timeboxedinvalid-signed
2035'
2036
2037test_expect_success GPGSM 'log x509 fingerprint' '
2038 echo "F8BF62E0693D0694816377099909C779FA23FD65 | " >expect &&
2039 git log -n1 --format="%GF | %GP" signed-x509 >actual &&
2040 test_cmp expect actual
2041'
2042
2043test_expect_success GPGSM 'log OpenPGP fingerprint' '
2044 echo "D4BE22311AD3131E5EDA29A461092E85B7227189" > expect &&
2045 git log -n1 --format="%GP" signed-subkey >actual &&
2046 test_cmp expect actual
2047'
2048
2049test_expect_success GPGSSH 'log ssh key fingerprint' '
2050 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2051 ssh-keygen -lf "${GPGSSH_KEY_PRIMARY}" | awk "{print \$2\" | \"}" >expect &&
2052 git log -n1 --format="%GF | %GP" signed-ssh >actual &&
2053 test_cmp expect actual
2054'
2055
2056test_expect_success GPG 'log --graph --show-signature' '
2057 git log --graph --show-signature -n1 signed >actual &&
2058 grep "^| gpg: Signature made" actual &&
2059 grep "^| gpg: Good signature" actual
2060'
2061
2062test_expect_success GPGSM 'log --graph --show-signature x509' '
2063 git log --graph --show-signature -n1 signed-x509 >actual &&
2064 grep "^| gpgsm: Signature made" actual &&
2065 grep "^| gpgsm: Good signature" actual
2066'
2067
2068test_expect_success GPGSSH 'log --graph --show-signature ssh' '
2069 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2070 git log --graph --show-signature -n1 signed-ssh >actual &&
2071 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2072'
2073
2074test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on expired signature key' '
2075 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2076 git log --graph --show-signature -n1 expired-signed >actual &&
2077 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2078'
2079
2080test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure on not yet valid signature key' '
2081 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2082 git log --graph --show-signature -n1 notyetvalid-signed >actual &&
2083 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2084'
2085
2086test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log show success with commit date and key validity matching' '
2087 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2088 git log --graph --show-signature -n1 timeboxedvalid-signed >actual &&
2089 grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual &&
2090 ! grep "${GPGSSH_BAD_SIGNATURE}" actual
2091'
2092
2093test_expect_success GPGSSH,GPGSSH_VERIFYTIME 'log shows failure with commit date outside of key validity' '
2094 test_config gpg.ssh.allowedSignersFile "${GPGSSH_ALLOWED_SIGNERS}" &&
2095 git log --graph --show-signature -n1 timeboxedinvalid-signed >actual &&
2096 ! grep "${GPGSSH_GOOD_SIGNATURE_TRUSTED}" actual
2097'
2098
2099test_expect_success GPG 'log --graph --show-signature for merged tag' '
2100 test_when_finished "git reset --hard && git checkout main" &&
2101 git checkout -b plain main &&
2102 echo aaa >bar &&
2103 git add bar &&
2104 git commit -m bar_commit &&
2105 git checkout -b tagged main &&
2106 echo bbb >baz &&
2107 git add baz &&
2108 git commit -m baz_commit &&
2109 git tag -s -m signed_tag_msg signed_tag &&
2110 git checkout plain &&
2111 git merge --no-ff -m msg signed_tag &&
2112 git log --graph --show-signature -n1 plain >actual &&
2113 grep "^|\\\ merged tag" actual &&
2114 grep "^| | gpg: Signature made" actual &&
2115 grep "^| | gpg: Good signature" actual
2116'
2117
2118test_expect_success GPG 'log --graph --show-signature for merged tag in shallow clone' '
2119 test_when_finished "git reset --hard && git checkout main" &&
2120 git checkout -b plain-shallow main &&
2121 echo aaa >bar &&
2122 git add bar &&
2123 git commit -m bar_commit &&
2124 git checkout --detach main &&
2125 echo bbb >baz &&
2126 git add baz &&
2127 git commit -m baz_commit &&
2128 git tag -s -m signed_tag_msg signed_tag_shallow &&
2129 hash=$(git rev-parse HEAD) &&
2130 git checkout plain-shallow &&
2131 git merge --no-ff -m msg signed_tag_shallow &&
2132 git clone --depth 1 --no-local . shallow &&
2133 test_when_finished "rm -rf shallow" &&
2134 git -C shallow log --graph --show-signature -n1 plain-shallow >actual &&
2135 grep "tag signed_tag_shallow names a non-parent $hash" actual
2136'
2137
2138test_expect_success GPG 'log --graph --show-signature for merged tag with missing key' '
2139 test_when_finished "git reset --hard && git checkout main" &&
2140 git checkout -b plain-nokey main &&
2141 echo aaa >bar &&
2142 git add bar &&
2143 git commit -m bar_commit &&
2144 git checkout -b tagged-nokey main &&
2145 echo bbb >baz &&
2146 git add baz &&
2147 git commit -m baz_commit &&
2148 git tag -s -m signed_tag_msg signed_tag_nokey &&
2149 git checkout plain-nokey &&
2150 git merge --no-ff -m msg signed_tag_nokey &&
2151 GNUPGHOME=. git log --graph --show-signature -n1 plain-nokey >actual &&
2152 grep "^|\\\ merged tag" actual &&
2153 grep "^| | gpg: Signature made" actual &&
2154 grep -E "^| | gpg: Can'"'"'t check signature: (public key not found|No public key)" actual
2155'
2156
2157test_expect_success GPG 'log --graph --show-signature for merged tag with bad signature' '
2158 test_when_finished "git reset --hard && git checkout main" &&
2159 git checkout -b plain-bad main &&
2160 echo aaa >bar &&
2161 git add bar &&
2162 git commit -m bar_commit &&
2163 git checkout -b tagged-bad main &&
2164 echo bbb >baz &&
2165 git add baz &&
2166 git commit -m baz_commit &&
2167 git tag -s -m signed_tag_msg signed_tag_bad &&
2168 git cat-file tag signed_tag_bad >raw &&
2169 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2170 git hash-object -w -t tag forged >forged.tag &&
2171 git checkout plain-bad &&
2172 git merge --no-ff -m msg "$(cat forged.tag)" &&
2173 git log --graph --show-signature -n1 plain-bad >actual &&
2174 grep "^|\\\ merged tag" actual &&
2175 grep "^| | gpg: Signature made" actual &&
2176 grep "^| | gpg: BAD signature from" actual
2177'
2178
2179test_expect_success GPG 'log --show-signature for merged tag with GPG failure' '
2180 test_when_finished "git reset --hard && git checkout main" &&
2181 git checkout -b plain-fail main &&
2182 echo aaa >bar &&
2183 git add bar &&
2184 git commit -m bar_commit &&
2185 git checkout -b tagged-fail main &&
2186 echo bbb >baz &&
2187 git add baz &&
2188 git commit -m baz_commit &&
2189 git tag -s -m signed_tag_msg signed_tag_fail &&
2190 git checkout plain-fail &&
2191 git merge --no-ff -m msg signed_tag_fail &&
2192 if ! test_have_prereq VALGRIND
2193 then
2194 TMPDIR="$(pwd)/bogus" git log --show-signature -n1 plain-fail >actual &&
2195 grep "^merged tag" actual &&
2196 grep "^No signature" actual &&
2197 ! grep "^gpg: Signature made" actual
2198 fi
2199'
2200
2201test_expect_success GPGSM 'log --graph --show-signature for merged tag x509' '
2202 test_when_finished "git reset --hard && git checkout main" &&
2203 test_config gpg.format x509 &&
2204 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2205 git checkout -b plain-x509 main &&
2206 echo aaa >bar &&
2207 git add bar &&
2208 git commit -m bar_commit &&
2209 git checkout -b tagged-x509 main &&
2210 echo bbb >baz &&
2211 git add baz &&
2212 git commit -m baz_commit &&
2213 git tag -s -m signed_tag_msg signed_tag_x509 &&
2214 git checkout plain-x509 &&
2215 git merge --no-ff -m msg signed_tag_x509 &&
2216 git log --graph --show-signature -n1 plain-x509 >actual &&
2217 grep "^|\\\ merged tag" actual &&
2218 grep "^| | gpgsm: Signature made" actual &&
2219 grep "^| | gpgsm: Good signature" actual
2220'
2221
2222test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 missing key' '
2223 test_when_finished "git reset --hard && git checkout main" &&
2224 test_config gpg.format x509 &&
2225 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2226 git checkout -b plain-x509-nokey main &&
2227 echo aaa >bar &&
2228 git add bar &&
2229 git commit -m bar_commit &&
2230 git checkout -b tagged-x509-nokey main &&
2231 echo bbb >baz &&
2232 git add baz &&
2233 git commit -m baz_commit &&
2234 git tag -s -m signed_tag_msg signed_tag_x509_nokey &&
2235 git checkout plain-x509-nokey &&
2236 git merge --no-ff -m msg signed_tag_x509_nokey &&
2237 GNUPGHOME=. git log --graph --show-signature -n1 plain-x509-nokey >actual &&
2238 grep "^|\\\ merged tag" actual &&
2239 grep -e "^| | gpgsm: certificate not found" \
2240 -e "^| | gpgsm: failed to find the certificate: Not found" actual
2241'
2242
2243test_expect_success GPGSM 'log --graph --show-signature for merged tag x509 bad signature' '
2244 test_when_finished "git reset --hard && git checkout main" &&
2245 test_config gpg.format x509 &&
2246 test_config user.signingkey $GIT_COMMITTER_EMAIL &&
2247 git checkout -b plain-x509-bad main &&
2248 echo aaa >bar &&
2249 git add bar &&
2250 git commit -m bar_commit &&
2251 git checkout -b tagged-x509-bad main &&
2252 echo bbb >baz &&
2253 git add baz &&
2254 git commit -m baz_commit &&
2255 git tag -s -m signed_tag_msg signed_tag_x509_bad &&
2256 git cat-file tag signed_tag_x509_bad >raw &&
2257 sed -e "s/signed_tag_msg/forged/" raw >forged &&
2258 git hash-object -w -t tag forged >forged.tag &&
2259 git checkout plain-x509-bad &&
2260 git merge --no-ff -m msg "$(cat forged.tag)" &&
2261 git log --graph --show-signature -n1 plain-x509-bad >actual &&
2262 grep "^|\\\ merged tag" actual &&
2263 grep "^| | gpgsm: Signature made" actual &&
2264 grep "^| | gpgsm: invalid signature" actual
2265'
2266
2267
2268test_expect_success GPG '--no-show-signature overrides --show-signature' '
2269 git log -1 --show-signature --no-show-signature signed >actual &&
2270 ! grep "^gpg:" actual
2271'
2272
2273test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
2274 test_config log.showsignature true &&
2275 git log -1 signed >actual &&
2276 grep "gpg: Signature made" actual &&
2277 grep "gpg: Good signature" actual
2278'
2279
2280test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
2281 test_config log.showsignature true &&
2282 git log -1 --no-show-signature signed >actual &&
2283 ! grep "^gpg:" actual
2284'
2285
2286test_expect_success GPG '--show-signature overrides log.showsignature=false' '
2287 test_config log.showsignature false &&
2288 git log -1 --show-signature signed >actual &&
2289 grep "gpg: Signature made" actual &&
2290 grep "gpg: Good signature" actual
2291'
2292
2293test_expect_success 'log --graph --no-walk is forbidden' '
2294 test_must_fail git log --graph --no-walk
2295'
2296
2297test_expect_success 'log on empty repo fails' '
2298 git init empty &&
2299 test_when_finished "rm -rf empty" &&
2300 test_must_fail git -C empty log 2>stderr &&
2301 test_grep does.not.have.any.commits stderr
2302'
2303
2304test_expect_success 'log does not default to HEAD when rev input is given' '
2305 git log --branches=does-not-exist >actual &&
2306 test_must_be_empty actual
2307'
2308
2309test_expect_success 'do not default to HEAD with ignored object on cmdline' '
2310 git log --ignore-missing $ZERO_OID >actual &&
2311 test_must_be_empty actual
2312'
2313
2314test_expect_success 'do not default to HEAD with ignored object on stdin' '
2315 echo $ZERO_OID | git log --ignore-missing --stdin >actual &&
2316 test_must_be_empty actual
2317'
2318
2319test_expect_success 'set up --source tests' '
2320 git checkout --orphan source-a &&
2321 test_commit one &&
2322 test_commit two &&
2323 git checkout -b source-b HEAD^ &&
2324 test_commit three
2325'
2326
2327test_expect_success 'log --source paints branch names' '
2328 cat >expect <<-EOF &&
2329 $(git rev-parse --short :/three) source-b three
2330 $(git rev-parse --short :/two ) source-a two
2331 $(git rev-parse --short :/one ) source-b one
2332 EOF
2333 git log --oneline --source source-a source-b >actual &&
2334 test_cmp expect actual
2335'
2336
2337test_expect_success 'log --source paints tag names' '
2338 git tag -m tagged source-tag &&
2339 cat >expect <<-EOF &&
2340 $(git rev-parse --short :/three) source-tag three
2341 $(git rev-parse --short :/two ) source-a two
2342 $(git rev-parse --short :/one ) source-tag one
2343 EOF
2344 git log --oneline --source source-tag source-a >actual &&
2345 test_cmp expect actual
2346'
2347
2348test_expect_success 'log --source paints symmetric ranges' '
2349 cat >expect <<-EOF &&
2350 $(git rev-parse --short :/three) source-b three
2351 $(git rev-parse --short :/two ) source-a two
2352 EOF
2353 git log --oneline --source source-a...source-b >actual &&
2354 test_cmp expect actual
2355'
2356
2357test_expect_success '--exclude-promisor-objects does not BUG-crash' '
2358 test_must_fail git log --exclude-promisor-objects source-a
2359'
2360
2361test_expect_success 'log --decorate includes all levels of tag annotated tags' '
2362 git checkout -b branch &&
2363 git commit --allow-empty -m "new commit" &&
2364 git tag lightweight HEAD &&
2365 git tag -m annotated annotated HEAD &&
2366 git tag -m double-0 double-0 HEAD &&
2367 git tag -m double-1 double-1 double-0 &&
2368 cat >expect <<-\EOF &&
2369 HEAD -> branch, tag: lightweight, tag: double-1, tag: double-0, tag: annotated
2370 EOF
2371 git log -1 --format="%D" >actual &&
2372 test_cmp expect actual
2373'
2374
2375test_expect_success 'log --decorate does not include things outside filter' '
2376 reflist="refs/prefetch refs/rebase-merge refs/bundle" &&
2377
2378 for ref in $reflist
2379 do
2380 git update-ref $ref/fake HEAD || return 1
2381 done &&
2382
2383 git log --decorate=full --oneline >actual &&
2384
2385 # None of the refs are visible:
2386 ! grep /fake actual
2387'
2388
2389test_expect_success 'log --end-of-options' '
2390 git update-ref refs/heads/--source HEAD &&
2391 git log --end-of-options --source >actual &&
2392 git log >expect &&
2393 test_cmp expect actual
2394'
2395
2396test_expect_success 'set up commits with different authors' '
2397 git checkout --orphan authors &&
2398 test_commit --author "Jim <jim@example.com>" jim_1 &&
2399 test_commit --author "Val <val@example.com>" val_1 &&
2400 test_commit --author "Val <val@example.com>" val_2 &&
2401 test_commit --author "Jim <jim@example.com>" jim_2 &&
2402 test_commit --author "Val <val@example.com>" val_3 &&
2403 test_commit --author "Jim <jim@example.com>" jim_3
2404'
2405
2406test_expect_success 'log --invert-grep --grep --author' '
2407 cat >expect <<-\EOF &&
2408 val_3
2409 val_1
2410 EOF
2411 git log --format=%s --author=Val --grep 2 --invert-grep >actual &&
2412 test_cmp expect actual
2413'
2414
2415test_done