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