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