1#!/bin/sh
2
3test_description='git log'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY/lib-gpg.sh"
7. "$TEST_DIRECTORY/lib-terminal.sh"
8
9test_expect_success setup '
10
11 echo one >one &&
12 git add one &&
13 test_tick &&
14 git commit -m initial &&
15
16 echo ichi >one &&
17 git add one &&
18 test_tick &&
19 git commit -m second &&
20
21 git mv one ichi &&
22 test_tick &&
23 git commit -m third &&
24
25 cp ichi ein &&
26 git add ein &&
27 test_tick &&
28 git commit -m fourth &&
29
30 mkdir a &&
31 echo ni >a/two &&
32 git add a/two &&
33 test_tick &&
34 git commit -m fifth &&
35
36 git rm a/two &&
37 test_tick &&
38 git commit -m sixth
39
40'
41
42printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
43test_expect_success 'pretty' '
44
45 git log --pretty="format:%s" > actual &&
46 test_cmp expect actual
47'
48
49printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
50test_expect_success 'pretty (tformat)' '
51
52 git log --pretty="tformat:%s" > actual &&
53 test_cmp expect actual
54'
55
56test_expect_success 'pretty (shortcut)' '
57
58 git log --pretty="%s" > actual &&
59 test_cmp expect actual
60'
61
62test_expect_success 'format' '
63
64 git log --format="%s" > actual &&
65 test_cmp expect actual
66'
67
68cat > expect << EOF
69 This is
70 the sixth
71 commit.
72 This is
73 the fifth
74 commit.
75EOF
76
77test_expect_success 'format %w(11,1,2)' '
78
79 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
80 test_cmp expect actual
81'
82
83test_expect_success 'format %w(,1,2)' '
84
85 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
86 test_cmp expect actual
87'
88
89cat > expect << EOF
90804a787 sixth
91394ef78 fifth
925d31159 fourth
932fbe8c0 third
94f7dab8e second
953a2fdcb initial
96EOF
97test_expect_success 'oneline' '
98
99 git log --oneline > actual &&
100 test_cmp expect actual
101'
102
103test_expect_success 'diff-filter=A' '
104
105 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
106 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
107 printf "fifth\nfourth\nthird\ninitial" > expect &&
108 test_cmp expect actual &&
109 test_cmp expect actual-separate
110
111'
112
113test_expect_success 'diff-filter=M' '
114
115 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
116 expect=$(echo second) &&
117 verbose test "$actual" = "$expect"
118
119'
120
121test_expect_success 'diff-filter=D' '
122
123 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
124 expect=$(echo sixth ; echo third) &&
125 verbose test "$actual" = "$expect"
126
127'
128
129test_expect_success 'diff-filter=R' '
130
131 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
132 expect=$(echo third) &&
133 verbose test "$actual" = "$expect"
134
135'
136
137test_expect_success 'diff-filter=C' '
138
139 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
140 expect=$(echo fourth) &&
141 verbose test "$actual" = "$expect"
142
143'
144
145test_expect_success 'git log --follow' '
146
147 actual=$(git log --follow --pretty="format:%s" ichi) &&
148 expect=$(echo third ; echo second ; echo initial) &&
149 verbose test "$actual" = "$expect"
150'
151
152test_expect_success 'git config log.follow works like --follow' '
153 test_config log.follow true &&
154 actual=$(git log --pretty="format:%s" ichi) &&
155 expect=$(echo third ; echo second ; echo initial) &&
156 verbose test "$actual" = "$expect"
157'
158
159test_expect_success 'git config log.follow does not die with multiple paths' '
160 test_config log.follow true &&
161 git log --pretty="format:%s" ichi ein
162'
163
164test_expect_success 'git config log.follow does not die with no paths' '
165 test_config log.follow true &&
166 git log --
167'
168
169test_expect_success 'git config log.follow is overridden by --no-follow' '
170 test_config log.follow true &&
171 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
172 expect="third" &&
173 verbose test "$actual" = "$expect"
174'
175
176cat > expect << EOF
177804a787 sixth
178394ef78 fifth
1795d31159 fourth
180EOF
181test_expect_success 'git log --no-walk <commits> sorts by commit time' '
182 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
183 test_cmp expect actual
184'
185
186test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
187 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
188 test_cmp expect actual
189'
190
191cat > expect << EOF
192=== 804a787 sixth
193=== 394ef78 fifth
194=== 5d31159 fourth
195EOF
196test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
197 git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
198 test_cmp expect actual
199'
200
201cat > expect << EOF
2025d31159 fourth
203804a787 sixth
204394ef78 fifth
205EOF
206test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
207 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
208 test_cmp expect actual
209'
210
211test_expect_success 'git show <commits> leaves list of commits as given' '
212 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
213 test_cmp expect actual
214'
215
216test_expect_success 'setup case sensitivity tests' '
217 echo case >one &&
218 test_tick &&
219 git add one &&
220 git commit -a -m Second
221'
222
223test_expect_success 'log --grep' '
224 echo second >expect &&
225 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
226 test_cmp expect actual
227'
228
229cat > expect << EOF
230second
231initial
232EOF
233test_expect_success 'log --invert-grep --grep' '
234 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
235 test_cmp expect actual
236'
237
238test_expect_success 'log --invert-grep --grep -i' '
239 echo initial >expect &&
240 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
241 test_cmp expect actual
242'
243
244test_expect_success 'log --grep option parsing' '
245 echo second >expect &&
246 git log -1 --pretty="tformat:%s" --grep sec >actual &&
247 test_cmp expect actual &&
248 test_must_fail git log -1 --pretty="tformat:%s" --grep
249'
250
251test_expect_success 'log -i --grep' '
252 echo Second >expect &&
253 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
254 test_cmp expect actual
255'
256
257test_expect_success 'log --grep -i' '
258 echo Second >expect &&
259 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
260 test_cmp expect actual
261'
262
263test_expect_success 'log -F -E --grep=<ere> uses ere' '
264 echo second >expect &&
265 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
266 test_cmp expect actual
267'
268
269test_expect_success 'log with grep.patternType configuration' '
270 >expect &&
271 git -c grep.patterntype=fixed \
272 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
273 test_cmp expect actual
274'
275
276test_expect_success 'log with grep.patternType configuration and command line' '
277 echo second >expect &&
278 git -c grep.patterntype=fixed \
279 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
280 test_cmp expect actual
281'
282
283cat > expect <<EOF
284* Second
285* sixth
286* fifth
287* fourth
288* third
289* second
290* initial
291EOF
292
293test_expect_success 'simple log --graph' '
294 git log --graph --pretty=tformat:%s >actual &&
295 test_cmp expect actual
296'
297
298cat > expect <<EOF
299123 * Second
300123 * sixth
301123 * fifth
302123 * fourth
303123 * third
304123 * second
305123 * initial
306EOF
307
308test_expect_success 'simple log --graph --line-prefix="123 "' '
309 git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
310 test_cmp expect actual
311'
312
313test_expect_success 'set up merge history' '
314 git checkout -b side HEAD~4 &&
315 test_commit side-1 1 1 &&
316 test_commit side-2 2 2 &&
317 git checkout master &&
318 git merge side
319'
320
321cat > expect <<\EOF
322* Merge branch 'side'
323|\
324| * side-2
325| * side-1
326* | Second
327* | sixth
328* | fifth
329* | fourth
330|/
331* third
332* second
333* initial
334EOF
335
336test_expect_success 'log --graph with merge' '
337 git log --graph --date-order --pretty=tformat:%s |
338 sed "s/ *\$//" >actual &&
339 test_cmp expect actual
340'
341
342cat > expect <<\EOF
343| | | * Merge branch 'side'
344| | | |\
345| | | | * side-2
346| | | | * side-1
347| | | * | Second
348| | | * | sixth
349| | | * | fifth
350| | | * | fourth
351| | | |/
352| | | * third
353| | | * second
354| | | * initial
355EOF
356
357test_expect_success 'log --graph --line-prefix="| | | " with merge' '
358 git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
359 sed "s/ *\$//" >actual &&
360 test_cmp expect actual
361'
362
363cat > expect.colors <<\EOF
364* Merge branch 'side'
365<BLUE>|<RESET><CYAN>\<RESET>
366<BLUE>|<RESET> * side-2
367<BLUE>|<RESET> * side-1
368* <CYAN>|<RESET> Second
369* <CYAN>|<RESET> sixth
370* <CYAN>|<RESET> fifth
371* <CYAN>|<RESET> fourth
372<CYAN>|<RESET><CYAN>/<RESET>
373* third
374* second
375* initial
376EOF
377
378test_expect_success 'log --graph with merge with log.graphColors' '
379 test_config log.graphColors " blue,invalid-color, cyan, red , " &&
380 git log --color=always --graph --date-order --pretty=tformat:%s |
381 test_decode_color | sed "s/ *\$//" >actual &&
382 test_cmp expect.colors actual
383'
384
385test_expect_success 'log --raw --graph -m with merge' '
386 git log --raw --graph --oneline -m master | head -n 500 >actual &&
387 grep "initial" actual
388'
389
390test_expect_success 'diff-tree --graph' '
391 git diff-tree --graph master^ | head -n 500 >actual &&
392 grep "one" actual
393'
394
395cat > expect <<\EOF
396* commit master
397|\ Merge: A B
398| | Author: A U Thor <author@example.com>
399| |
400| | Merge branch 'side'
401| |
402| * commit tags/side-2
403| | Author: A U Thor <author@example.com>
404| |
405| | side-2
406| |
407| * commit tags/side-1
408| | Author: A U Thor <author@example.com>
409| |
410| | side-1
411| |
412* | commit master~1
413| | Author: A U Thor <author@example.com>
414| |
415| | Second
416| |
417* | commit master~2
418| | Author: A U Thor <author@example.com>
419| |
420| | sixth
421| |
422* | commit master~3
423| | Author: A U Thor <author@example.com>
424| |
425| | fifth
426| |
427* | commit master~4
428|/ Author: A U Thor <author@example.com>
429|
430| fourth
431|
432* commit tags/side-1~1
433| Author: A U Thor <author@example.com>
434|
435| third
436|
437* commit tags/side-1~2
438| Author: A U Thor <author@example.com>
439|
440| second
441|
442* commit tags/side-1~3
443 Author: A U Thor <author@example.com>
444
445 initial
446EOF
447
448test_expect_success 'log --graph with full output' '
449 git log --graph --date-order --pretty=short |
450 git name-rev --name-only --stdin |
451 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
452 test_cmp expect actual
453'
454
455test_expect_success 'set up more tangled history' '
456 git checkout -b tangle HEAD~6 &&
457 test_commit tangle-a tangle-a a &&
458 git merge master~3 &&
459 git merge side~1 &&
460 git checkout master &&
461 git merge tangle &&
462 git checkout -b reach &&
463 test_commit reach &&
464 git checkout master &&
465 git checkout -b octopus-a &&
466 test_commit octopus-a &&
467 git checkout master &&
468 git checkout -b octopus-b &&
469 test_commit octopus-b &&
470 git checkout master &&
471 test_commit seventh &&
472 git merge octopus-a octopus-b &&
473 git merge reach
474'
475
476cat > expect <<\EOF
477* Merge tag 'reach'
478|\
479| \
480| \
481*-. \ Merge tags 'octopus-a' and 'octopus-b'
482|\ \ \
483* | | | seventh
484| | * | octopus-b
485| |/ /
486|/| |
487| * | octopus-a
488|/ /
489| * reach
490|/
491* Merge branch 'tangle'
492|\
493| * Merge branch 'side' (early part) into tangle
494| |\
495| * \ Merge branch 'master' (early part) into tangle
496| |\ \
497| * | | tangle-a
498* | | | Merge branch 'side'
499|\ \ \ \
500| * | | | side-2
501| | |_|/
502| |/| |
503| * | | side-1
504* | | | Second
505* | | | sixth
506| |_|/
507|/| |
508* | | fifth
509* | | fourth
510|/ /
511* | third
512|/
513* second
514* initial
515EOF
516
517test_expect_success 'log --graph with merge' '
518 git log --graph --date-order --pretty=tformat:%s |
519 sed "s/ *\$//" >actual &&
520 test_cmp expect actual
521'
522
523test_expect_success 'log.decorate configuration' '
524 git log --oneline --no-decorate >expect.none &&
525 git log --oneline --decorate >expect.short &&
526 git log --oneline --decorate=full >expect.full &&
527
528 echo "[log] decorate" >>.git/config &&
529 git log --oneline >actual &&
530 test_cmp expect.short actual &&
531
532 test_config log.decorate true &&
533 git log --oneline >actual &&
534 test_cmp expect.short actual &&
535 git log --oneline --decorate=full >actual &&
536 test_cmp expect.full actual &&
537 git log --oneline --decorate=no >actual &&
538 test_cmp expect.none actual &&
539
540 test_config log.decorate no &&
541 git log --oneline >actual &&
542 test_cmp expect.none actual &&
543 git log --oneline --decorate >actual &&
544 test_cmp expect.short actual &&
545 git log --oneline --decorate=full >actual &&
546 test_cmp expect.full actual &&
547
548 test_config log.decorate 1 &&
549 git log --oneline >actual &&
550 test_cmp expect.short actual &&
551 git log --oneline --decorate=full >actual &&
552 test_cmp expect.full actual &&
553 git log --oneline --decorate=no >actual &&
554 test_cmp expect.none actual &&
555
556 test_config log.decorate short &&
557 git log --oneline >actual &&
558 test_cmp expect.short actual &&
559 git log --oneline --no-decorate >actual &&
560 test_cmp expect.none actual &&
561 git log --oneline --decorate=full >actual &&
562 test_cmp expect.full actual &&
563
564 test_config log.decorate full &&
565 git log --oneline >actual &&
566 test_cmp expect.full actual &&
567 git log --oneline --no-decorate >actual &&
568 test_cmp expect.none actual &&
569 git log --oneline --decorate >actual &&
570 test_cmp expect.short actual &&
571
572 test_unconfig log.decorate &&
573 git log --pretty=raw >expect.raw &&
574 test_config log.decorate full &&
575 git log --pretty=raw >actual &&
576 test_cmp expect.raw actual
577
578'
579
580test_expect_success 'log.decorate config parsing' '
581 git log --oneline --decorate=full >expect.full &&
582 git log --oneline --decorate=short >expect.short &&
583
584 test_config log.decorate full &&
585 test_config log.mailmap true &&
586 git log --oneline >actual &&
587 test_cmp expect.full actual &&
588 git log --oneline --decorate=short >actual &&
589 test_cmp expect.short actual
590'
591
592test_expect_success TTY 'log output on a TTY' '
593 git log --oneline --decorate >expect.short &&
594
595 test_terminal git log --oneline >actual &&
596 test_cmp expect.short actual
597'
598
599test_expect_success 'reflog is expected format' '
600 git log -g --abbrev-commit --pretty=oneline >expect &&
601 git reflog >actual &&
602 test_cmp expect actual
603'
604
605test_expect_success 'whatchanged is expected format' '
606 git log --no-merges --raw >expect &&
607 git whatchanged >actual &&
608 test_cmp expect actual
609'
610
611test_expect_success 'log.abbrevCommit configuration' '
612 git log --abbrev-commit >expect.log.abbrev &&
613 git log --no-abbrev-commit >expect.log.full &&
614 git log --pretty=raw >expect.log.raw &&
615 git reflog --abbrev-commit >expect.reflog.abbrev &&
616 git reflog --no-abbrev-commit >expect.reflog.full &&
617 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
618 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
619
620 test_config log.abbrevCommit true &&
621
622 git log >actual &&
623 test_cmp expect.log.abbrev actual &&
624 git log --no-abbrev-commit >actual &&
625 test_cmp expect.log.full actual &&
626
627 git log --pretty=raw >actual &&
628 test_cmp expect.log.raw actual &&
629
630 git reflog >actual &&
631 test_cmp expect.reflog.abbrev actual &&
632 git reflog --no-abbrev-commit >actual &&
633 test_cmp expect.reflog.full actual &&
634
635 git whatchanged >actual &&
636 test_cmp expect.whatchanged.abbrev actual &&
637 git whatchanged --no-abbrev-commit >actual &&
638 test_cmp expect.whatchanged.full actual
639'
640
641test_expect_success 'show added path under "--follow -M"' '
642 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
643 test_create_repo regression &&
644 (
645 cd regression &&
646 test_commit needs-another-commit &&
647 test_commit foo.bar &&
648 git log -M --follow -p foo.bar.t &&
649 git log -M --follow --stat foo.bar.t &&
650 git log -M --follow --name-only foo.bar.t
651 )
652'
653
654test_expect_success 'git log -c --follow' '
655 test_create_repo follow-c &&
656 (
657 cd follow-c &&
658 test_commit initial file original &&
659 git rm file &&
660 test_commit rename file2 original &&
661 git reset --hard initial &&
662 test_commit modify file foo &&
663 git merge -m merge rename &&
664 git log -c --follow file2
665 )
666'
667
668cat >expect <<\EOF
669* commit COMMIT_OBJECT_NAME
670|\ Merge: MERGE_PARENTS
671| | Author: A U Thor <author@example.com>
672| |
673| | Merge HEADS DESCRIPTION
674| |
675| * commit COMMIT_OBJECT_NAME
676| | Author: A U Thor <author@example.com>
677| |
678| | reach
679| | ---
680| | reach.t | 1 +
681| | 1 file changed, 1 insertion(+)
682| |
683| | diff --git a/reach.t b/reach.t
684| | new file mode 100644
685| | index 0000000..10c9591
686| | --- /dev/null
687| | +++ b/reach.t
688| | @@ -0,0 +1 @@
689| | +reach
690| |
691| \
692*-. \ commit COMMIT_OBJECT_NAME
693|\ \ \ Merge: MERGE_PARENTS
694| | | | Author: A U Thor <author@example.com>
695| | | |
696| | | | Merge HEADS DESCRIPTION
697| | | |
698| | * | commit COMMIT_OBJECT_NAME
699| | |/ Author: A U Thor <author@example.com>
700| | |
701| | | octopus-b
702| | | ---
703| | | octopus-b.t | 1 +
704| | | 1 file changed, 1 insertion(+)
705| | |
706| | | diff --git a/octopus-b.t b/octopus-b.t
707| | | new file mode 100644
708| | | index 0000000..d5fcad0
709| | | --- /dev/null
710| | | +++ b/octopus-b.t
711| | | @@ -0,0 +1 @@
712| | | +octopus-b
713| | |
714| * | commit COMMIT_OBJECT_NAME
715| |/ Author: A U Thor <author@example.com>
716| |
717| | octopus-a
718| | ---
719| | octopus-a.t | 1 +
720| | 1 file changed, 1 insertion(+)
721| |
722| | diff --git a/octopus-a.t b/octopus-a.t
723| | new file mode 100644
724| | index 0000000..11ee015
725| | --- /dev/null
726| | +++ b/octopus-a.t
727| | @@ -0,0 +1 @@
728| | +octopus-a
729| |
730* | commit COMMIT_OBJECT_NAME
731|/ Author: A U Thor <author@example.com>
732|
733| seventh
734| ---
735| seventh.t | 1 +
736| 1 file changed, 1 insertion(+)
737|
738| diff --git a/seventh.t b/seventh.t
739| new file mode 100644
740| index 0000000..9744ffc
741| --- /dev/null
742| +++ b/seventh.t
743| @@ -0,0 +1 @@
744| +seventh
745|
746* commit COMMIT_OBJECT_NAME
747|\ Merge: MERGE_PARENTS
748| | Author: A U Thor <author@example.com>
749| |
750| | Merge branch 'tangle'
751| |
752| * commit COMMIT_OBJECT_NAME
753| |\ Merge: MERGE_PARENTS
754| | | Author: A U Thor <author@example.com>
755| | |
756| | | Merge branch 'side' (early part) into tangle
757| | |
758| * | commit COMMIT_OBJECT_NAME
759| |\ \ Merge: MERGE_PARENTS
760| | | | Author: A U Thor <author@example.com>
761| | | |
762| | | | Merge branch 'master' (early part) into tangle
763| | | |
764| * | | commit COMMIT_OBJECT_NAME
765| | | | Author: A U Thor <author@example.com>
766| | | |
767| | | | tangle-a
768| | | | ---
769| | | | tangle-a | 1 +
770| | | | 1 file changed, 1 insertion(+)
771| | | |
772| | | | diff --git a/tangle-a b/tangle-a
773| | | | new file mode 100644
774| | | | index 0000000..7898192
775| | | | --- /dev/null
776| | | | +++ b/tangle-a
777| | | | @@ -0,0 +1 @@
778| | | | +a
779| | | |
780* | | | commit COMMIT_OBJECT_NAME
781|\ \ \ \ Merge: MERGE_PARENTS
782| | | | | Author: A U Thor <author@example.com>
783| | | | |
784| | | | | Merge branch 'side'
785| | | | |
786| * | | | commit COMMIT_OBJECT_NAME
787| | |_|/ Author: A U Thor <author@example.com>
788| |/| |
789| | | | side-2
790| | | | ---
791| | | | 2 | 1 +
792| | | | 1 file changed, 1 insertion(+)
793| | | |
794| | | | diff --git a/2 b/2
795| | | | new file mode 100644
796| | | | index 0000000..0cfbf08
797| | | | --- /dev/null
798| | | | +++ b/2
799| | | | @@ -0,0 +1 @@
800| | | | +2
801| | | |
802| * | | commit COMMIT_OBJECT_NAME
803| | | | Author: A U Thor <author@example.com>
804| | | |
805| | | | side-1
806| | | | ---
807| | | | 1 | 1 +
808| | | | 1 file changed, 1 insertion(+)
809| | | |
810| | | | diff --git a/1 b/1
811| | | | new file mode 100644
812| | | | index 0000000..d00491f
813| | | | --- /dev/null
814| | | | +++ b/1
815| | | | @@ -0,0 +1 @@
816| | | | +1
817| | | |
818* | | | commit COMMIT_OBJECT_NAME
819| | | | Author: A U Thor <author@example.com>
820| | | |
821| | | | Second
822| | | | ---
823| | | | one | 1 +
824| | | | 1 file changed, 1 insertion(+)
825| | | |
826| | | | diff --git a/one b/one
827| | | | new file mode 100644
828| | | | index 0000000..9a33383
829| | | | --- /dev/null
830| | | | +++ b/one
831| | | | @@ -0,0 +1 @@
832| | | | +case
833| | | |
834* | | | commit COMMIT_OBJECT_NAME
835| |_|/ Author: A U Thor <author@example.com>
836|/| |
837| | | sixth
838| | | ---
839| | | a/two | 1 -
840| | | 1 file changed, 1 deletion(-)
841| | |
842| | | diff --git a/a/two b/a/two
843| | | deleted file mode 100644
844| | | index 9245af5..0000000
845| | | --- a/a/two
846| | | +++ /dev/null
847| | | @@ -1 +0,0 @@
848| | | -ni
849| | |
850* | | commit COMMIT_OBJECT_NAME
851| | | Author: A U Thor <author@example.com>
852| | |
853| | | fifth
854| | | ---
855| | | a/two | 1 +
856| | | 1 file changed, 1 insertion(+)
857| | |
858| | | diff --git a/a/two b/a/two
859| | | new file mode 100644
860| | | index 0000000..9245af5
861| | | --- /dev/null
862| | | +++ b/a/two
863| | | @@ -0,0 +1 @@
864| | | +ni
865| | |
866* | | commit COMMIT_OBJECT_NAME
867|/ / Author: A U Thor <author@example.com>
868| |
869| | fourth
870| | ---
871| | ein | 1 +
872| | 1 file changed, 1 insertion(+)
873| |
874| | diff --git a/ein b/ein
875| | new file mode 100644
876| | index 0000000..9d7e69f
877| | --- /dev/null
878| | +++ b/ein
879| | @@ -0,0 +1 @@
880| | +ichi
881| |
882* | commit COMMIT_OBJECT_NAME
883|/ Author: A U Thor <author@example.com>
884|
885| third
886| ---
887| ichi | 1 +
888| one | 1 -
889| 2 files changed, 1 insertion(+), 1 deletion(-)
890|
891| diff --git a/ichi b/ichi
892| new file mode 100644
893| index 0000000..9d7e69f
894| --- /dev/null
895| +++ b/ichi
896| @@ -0,0 +1 @@
897| +ichi
898| diff --git a/one b/one
899| deleted file mode 100644
900| index 9d7e69f..0000000
901| --- a/one
902| +++ /dev/null
903| @@ -1 +0,0 @@
904| -ichi
905|
906* commit COMMIT_OBJECT_NAME
907| Author: A U Thor <author@example.com>
908|
909| second
910| ---
911| one | 2 +-
912| 1 file changed, 1 insertion(+), 1 deletion(-)
913|
914| diff --git a/one b/one
915| index 5626abf..9d7e69f 100644
916| --- a/one
917| +++ b/one
918| @@ -1 +1 @@
919| -one
920| +ichi
921|
922* commit COMMIT_OBJECT_NAME
923 Author: A U Thor <author@example.com>
924
925 initial
926 ---
927 one | 1 +
928 1 file changed, 1 insertion(+)
929
930 diff --git a/one b/one
931 new file mode 100644
932 index 0000000..5626abf
933 --- /dev/null
934 +++ b/one
935 @@ -0,0 +1 @@
936 +one
937EOF
938
939sanitize_output () {
940 sed -e 's/ *$//' \
941 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
942 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
943 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
944 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
945 -e 's/, 0 deletions(-)//' \
946 -e 's/, 0 insertions(+)//' \
947 -e 's/ 1 files changed, / 1 file changed, /' \
948 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
949 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
950}
951
952test_expect_success 'log --graph with diff and stats' '
953 git log --no-renames --graph --pretty=short --stat -p >actual &&
954 sanitize_output >actual.sanitized <actual &&
955 test_i18ncmp expect actual.sanitized
956'
957
958cat >expect <<\EOF
959*** * commit COMMIT_OBJECT_NAME
960*** |\ Merge: MERGE_PARENTS
961*** | | Author: A U Thor <author@example.com>
962*** | |
963*** | | Merge HEADS DESCRIPTION
964*** | |
965*** | * commit COMMIT_OBJECT_NAME
966*** | | Author: A U Thor <author@example.com>
967*** | |
968*** | | reach
969*** | | ---
970*** | | reach.t | 1 +
971*** | | 1 file changed, 1 insertion(+)
972*** | |
973*** | | diff --git a/reach.t b/reach.t
974*** | | new file mode 100644
975*** | | index 0000000..10c9591
976*** | | --- /dev/null
977*** | | +++ b/reach.t
978*** | | @@ -0,0 +1 @@
979*** | | +reach
980*** | |
981*** | \
982*** *-. \ commit COMMIT_OBJECT_NAME
983*** |\ \ \ Merge: MERGE_PARENTS
984*** | | | | Author: A U Thor <author@example.com>
985*** | | | |
986*** | | | | Merge HEADS DESCRIPTION
987*** | | | |
988*** | | * | commit COMMIT_OBJECT_NAME
989*** | | |/ Author: A U Thor <author@example.com>
990*** | | |
991*** | | | octopus-b
992*** | | | ---
993*** | | | octopus-b.t | 1 +
994*** | | | 1 file changed, 1 insertion(+)
995*** | | |
996*** | | | diff --git a/octopus-b.t b/octopus-b.t
997*** | | | new file mode 100644
998*** | | | index 0000000..d5fcad0
999*** | | | --- /dev/null
1000*** | | | +++ b/octopus-b.t
1001*** | | | @@ -0,0 +1 @@
1002*** | | | +octopus-b
1003*** | | |
1004*** | * | commit COMMIT_OBJECT_NAME
1005*** | |/ Author: A U Thor <author@example.com>
1006*** | |
1007*** | | octopus-a
1008*** | | ---
1009*** | | octopus-a.t | 1 +
1010*** | | 1 file changed, 1 insertion(+)
1011*** | |
1012*** | | diff --git a/octopus-a.t b/octopus-a.t
1013*** | | new file mode 100644
1014*** | | index 0000000..11ee015
1015*** | | --- /dev/null
1016*** | | +++ b/octopus-a.t
1017*** | | @@ -0,0 +1 @@
1018*** | | +octopus-a
1019*** | |
1020*** * | commit COMMIT_OBJECT_NAME
1021*** |/ Author: A U Thor <author@example.com>
1022*** |
1023*** | seventh
1024*** | ---
1025*** | seventh.t | 1 +
1026*** | 1 file changed, 1 insertion(+)
1027*** |
1028*** | diff --git a/seventh.t b/seventh.t
1029*** | new file mode 100644
1030*** | index 0000000..9744ffc
1031*** | --- /dev/null
1032*** | +++ b/seventh.t
1033*** | @@ -0,0 +1 @@
1034*** | +seventh
1035*** |
1036*** * commit COMMIT_OBJECT_NAME
1037*** |\ Merge: MERGE_PARENTS
1038*** | | Author: A U Thor <author@example.com>
1039*** | |
1040*** | | Merge branch 'tangle'
1041*** | |
1042*** | * commit COMMIT_OBJECT_NAME
1043*** | |\ Merge: MERGE_PARENTS
1044*** | | | Author: A U Thor <author@example.com>
1045*** | | |
1046*** | | | Merge branch 'side' (early part) into tangle
1047*** | | |
1048*** | * | commit COMMIT_OBJECT_NAME
1049*** | |\ \ Merge: MERGE_PARENTS
1050*** | | | | Author: A U Thor <author@example.com>
1051*** | | | |
1052*** | | | | Merge branch 'master' (early part) into tangle
1053*** | | | |
1054*** | * | | commit COMMIT_OBJECT_NAME
1055*** | | | | Author: A U Thor <author@example.com>
1056*** | | | |
1057*** | | | | tangle-a
1058*** | | | | ---
1059*** | | | | tangle-a | 1 +
1060*** | | | | 1 file changed, 1 insertion(+)
1061*** | | | |
1062*** | | | | diff --git a/tangle-a b/tangle-a
1063*** | | | | new file mode 100644
1064*** | | | | index 0000000..7898192
1065*** | | | | --- /dev/null
1066*** | | | | +++ b/tangle-a
1067*** | | | | @@ -0,0 +1 @@
1068*** | | | | +a
1069*** | | | |
1070*** * | | | commit COMMIT_OBJECT_NAME
1071*** |\ \ \ \ Merge: MERGE_PARENTS
1072*** | | | | | Author: A U Thor <author@example.com>
1073*** | | | | |
1074*** | | | | | Merge branch 'side'
1075*** | | | | |
1076*** | * | | | commit COMMIT_OBJECT_NAME
1077*** | | |_|/ Author: A U Thor <author@example.com>
1078*** | |/| |
1079*** | | | | side-2
1080*** | | | | ---
1081*** | | | | 2 | 1 +
1082*** | | | | 1 file changed, 1 insertion(+)
1083*** | | | |
1084*** | | | | diff --git a/2 b/2
1085*** | | | | new file mode 100644
1086*** | | | | index 0000000..0cfbf08
1087*** | | | | --- /dev/null
1088*** | | | | +++ b/2
1089*** | | | | @@ -0,0 +1 @@
1090*** | | | | +2
1091*** | | | |
1092*** | * | | commit COMMIT_OBJECT_NAME
1093*** | | | | Author: A U Thor <author@example.com>
1094*** | | | |
1095*** | | | | side-1
1096*** | | | | ---
1097*** | | | | 1 | 1 +
1098*** | | | | 1 file changed, 1 insertion(+)
1099*** | | | |
1100*** | | | | diff --git a/1 b/1
1101*** | | | | new file mode 100644
1102*** | | | | index 0000000..d00491f
1103*** | | | | --- /dev/null
1104*** | | | | +++ b/1
1105*** | | | | @@ -0,0 +1 @@
1106*** | | | | +1
1107*** | | | |
1108*** * | | | commit COMMIT_OBJECT_NAME
1109*** | | | | Author: A U Thor <author@example.com>
1110*** | | | |
1111*** | | | | Second
1112*** | | | | ---
1113*** | | | | one | 1 +
1114*** | | | | 1 file changed, 1 insertion(+)
1115*** | | | |
1116*** | | | | diff --git a/one b/one
1117*** | | | | new file mode 100644
1118*** | | | | index 0000000..9a33383
1119*** | | | | --- /dev/null
1120*** | | | | +++ b/one
1121*** | | | | @@ -0,0 +1 @@
1122*** | | | | +case
1123*** | | | |
1124*** * | | | commit COMMIT_OBJECT_NAME
1125*** | |_|/ Author: A U Thor <author@example.com>
1126*** |/| |
1127*** | | | sixth
1128*** | | | ---
1129*** | | | a/two | 1 -
1130*** | | | 1 file changed, 1 deletion(-)
1131*** | | |
1132*** | | | diff --git a/a/two b/a/two
1133*** | | | deleted file mode 100644
1134*** | | | index 9245af5..0000000
1135*** | | | --- a/a/two
1136*** | | | +++ /dev/null
1137*** | | | @@ -1 +0,0 @@
1138*** | | | -ni
1139*** | | |
1140*** * | | commit COMMIT_OBJECT_NAME
1141*** | | | Author: A U Thor <author@example.com>
1142*** | | |
1143*** | | | fifth
1144*** | | | ---
1145*** | | | a/two | 1 +
1146*** | | | 1 file changed, 1 insertion(+)
1147*** | | |
1148*** | | | diff --git a/a/two b/a/two
1149*** | | | new file mode 100644
1150*** | | | index 0000000..9245af5
1151*** | | | --- /dev/null
1152*** | | | +++ b/a/two
1153*** | | | @@ -0,0 +1 @@
1154*** | | | +ni
1155*** | | |
1156*** * | | commit COMMIT_OBJECT_NAME
1157*** |/ / Author: A U Thor <author@example.com>
1158*** | |
1159*** | | fourth
1160*** | | ---
1161*** | | ein | 1 +
1162*** | | 1 file changed, 1 insertion(+)
1163*** | |
1164*** | | diff --git a/ein b/ein
1165*** | | new file mode 100644
1166*** | | index 0000000..9d7e69f
1167*** | | --- /dev/null
1168*** | | +++ b/ein
1169*** | | @@ -0,0 +1 @@
1170*** | | +ichi
1171*** | |
1172*** * | commit COMMIT_OBJECT_NAME
1173*** |/ Author: A U Thor <author@example.com>
1174*** |
1175*** | third
1176*** | ---
1177*** | ichi | 1 +
1178*** | one | 1 -
1179*** | 2 files changed, 1 insertion(+), 1 deletion(-)
1180*** |
1181*** | diff --git a/ichi b/ichi
1182*** | new file mode 100644
1183*** | index 0000000..9d7e69f
1184*** | --- /dev/null
1185*** | +++ b/ichi
1186*** | @@ -0,0 +1 @@
1187*** | +ichi
1188*** | diff --git a/one b/one
1189*** | deleted file mode 100644
1190*** | index 9d7e69f..0000000
1191*** | --- a/one
1192*** | +++ /dev/null
1193*** | @@ -1 +0,0 @@
1194*** | -ichi
1195*** |
1196*** * commit COMMIT_OBJECT_NAME
1197*** | Author: A U Thor <author@example.com>
1198*** |
1199*** | second
1200*** | ---
1201*** | one | 2 +-
1202*** | 1 file changed, 1 insertion(+), 1 deletion(-)
1203*** |
1204*** | diff --git a/one b/one
1205*** | index 5626abf..9d7e69f 100644
1206*** | --- a/one
1207*** | +++ b/one
1208*** | @@ -1 +1 @@
1209*** | -one
1210*** | +ichi
1211*** |
1212*** * commit COMMIT_OBJECT_NAME
1213*** Author: A U Thor <author@example.com>
1214***
1215*** initial
1216*** ---
1217*** one | 1 +
1218*** 1 file changed, 1 insertion(+)
1219***
1220*** diff --git a/one b/one
1221*** new file mode 100644
1222*** index 0000000..5626abf
1223*** --- /dev/null
1224*** +++ b/one
1225*** @@ -0,0 +1 @@
1226*** +one
1227EOF
1228
1229test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1230 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1231 sanitize_output >actual.sanitized <actual &&
1232 test_i18ncmp expect actual.sanitized
1233'
1234
1235cat >expect <<-\EOF
1236* reach
1237|
1238| A reach.t
1239* Merge branch 'tangle'
1240* Merge branch 'side'
1241|\
1242| * side-2
1243|
1244| A 2
1245* Second
1246|
1247| A one
1248* sixth
1249
1250 D a/two
1251EOF
1252
1253test_expect_success 'log --graph with --name-status' '
1254 git log --graph --format=%s --name-status tangle..reach >actual &&
1255 sanitize_output <actual >actual.sanitized &&
1256 test_cmp expect actual.sanitized
1257'
1258
1259cat >expect <<-\EOF
1260* reach
1261|
1262| reach.t
1263* Merge branch 'tangle'
1264* Merge branch 'side'
1265|\
1266| * side-2
1267|
1268| 2
1269* Second
1270|
1271| one
1272* sixth
1273
1274 a/two
1275EOF
1276
1277test_expect_success 'log --graph with --name-only' '
1278 git log --graph --format=%s --name-only tangle..reach >actual &&
1279 sanitize_output <actual >actual.sanitized &&
1280 test_cmp expect actual.sanitized
1281'
1282
1283test_expect_success 'dotdot is a parent directory' '
1284 mkdir -p a/b &&
1285 ( echo sixth && echo fifth ) >expect &&
1286 ( cd a/b && git log --format=%s .. ) >actual &&
1287 test_cmp expect actual
1288'
1289
1290test_expect_success GPG 'setup signed branch' '
1291 test_when_finished "git reset --hard && git checkout master" &&
1292 git checkout -b signed master &&
1293 echo foo >foo &&
1294 git add foo &&
1295 git commit -S -m signed_commit
1296'
1297
1298test_expect_success GPG 'log --graph --show-signature' '
1299 git log --graph --show-signature -n1 signed >actual &&
1300 grep "^| gpg: Signature made" actual &&
1301 grep "^| gpg: Good signature" actual
1302'
1303
1304test_expect_success GPG 'log --graph --show-signature for merged tag' '
1305 test_when_finished "git reset --hard && git checkout master" &&
1306 git checkout -b plain master &&
1307 echo aaa >bar &&
1308 git add bar &&
1309 git commit -m bar_commit &&
1310 git checkout -b tagged master &&
1311 echo bbb >baz &&
1312 git add baz &&
1313 git commit -m baz_commit &&
1314 git tag -s -m signed_tag_msg signed_tag &&
1315 git checkout plain &&
1316 git merge --no-ff -m msg signed_tag &&
1317 git log --graph --show-signature -n1 plain >actual &&
1318 grep "^|\\\ merged tag" actual &&
1319 grep "^| | gpg: Signature made" actual &&
1320 grep "^| | gpg: Good signature" actual
1321'
1322
1323test_expect_success GPG '--no-show-signature overrides --show-signature' '
1324 git log -1 --show-signature --no-show-signature signed >actual &&
1325 ! grep "^gpg:" actual
1326'
1327
1328test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1329 test_config log.showsignature true &&
1330 git log -1 signed >actual &&
1331 grep "gpg: Signature made" actual &&
1332 grep "gpg: Good signature" actual
1333'
1334
1335test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1336 test_config log.showsignature true &&
1337 git log -1 --no-show-signature signed >actual &&
1338 ! grep "^gpg:" actual
1339'
1340
1341test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1342 test_config log.showsignature false &&
1343 git log -1 --show-signature signed >actual &&
1344 grep "gpg: Signature made" actual &&
1345 grep "gpg: Good signature" actual
1346'
1347
1348test_expect_success 'log --graph --no-walk is forbidden' '
1349 test_must_fail git log --graph --no-walk
1350'
1351
1352test_expect_success 'log diagnoses bogus HEAD' '
1353 git init empty &&
1354 test_must_fail git -C empty log 2>stderr &&
1355 test_i18ngrep does.not.have.any.commits stderr &&
1356 echo 1234abcd >empty/.git/refs/heads/master &&
1357 test_must_fail git -C empty log 2>stderr &&
1358 test_i18ngrep broken stderr &&
1359 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1360 test_must_fail git -C empty log 2>stderr &&
1361 test_i18ngrep broken stderr &&
1362 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1363 test_i18ngrep broken stderr
1364'
1365
1366test_expect_success 'set up --source tests' '
1367 git checkout --orphan source-a &&
1368 test_commit one &&
1369 test_commit two &&
1370 git checkout -b source-b HEAD^ &&
1371 test_commit three
1372'
1373
1374test_expect_success 'log --source paints branch names' '
1375 cat >expect <<-\EOF &&
1376 09e12a9 source-b three
1377 8e393e1 source-a two
1378 1ac6c77 source-b one
1379 EOF
1380 git log --oneline --source source-a source-b >actual &&
1381 test_cmp expect actual
1382'
1383
1384test_expect_success 'log --source paints tag names' '
1385 git tag -m tagged source-tag &&
1386 cat >expect <<-\EOF &&
1387 09e12a9 source-tag three
1388 8e393e1 source-a two
1389 1ac6c77 source-tag one
1390 EOF
1391 git log --oneline --source source-tag source-a >actual &&
1392 test_cmp expect actual
1393'
1394
1395test_expect_success 'log --source paints symmetric ranges' '
1396 cat >expect <<-\EOF &&
1397 09e12a9 source-b three
1398 8e393e1 source-a two
1399 EOF
1400 git log --oneline --source source-a...source-b >actual &&
1401 test_cmp expect actual
1402'
1403
1404test_done