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 side
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 TTY 'log output on a TTY' '
581 git log --oneline --decorate >expect.short &&
582
583 test_terminal git log --oneline >actual &&
584 test_cmp expect.short actual
585'
586
587test_expect_success 'reflog is expected format' '
588 git log -g --abbrev-commit --pretty=oneline >expect &&
589 git reflog >actual &&
590 test_cmp expect actual
591'
592
593test_expect_success 'whatchanged is expected format' '
594 git log --no-merges --raw >expect &&
595 git whatchanged >actual &&
596 test_cmp expect actual
597'
598
599test_expect_success 'log.abbrevCommit configuration' '
600 git log --abbrev-commit >expect.log.abbrev &&
601 git log --no-abbrev-commit >expect.log.full &&
602 git log --pretty=raw >expect.log.raw &&
603 git reflog --abbrev-commit >expect.reflog.abbrev &&
604 git reflog --no-abbrev-commit >expect.reflog.full &&
605 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
606 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
607
608 test_config log.abbrevCommit true &&
609
610 git log >actual &&
611 test_cmp expect.log.abbrev actual &&
612 git log --no-abbrev-commit >actual &&
613 test_cmp expect.log.full actual &&
614
615 git log --pretty=raw >actual &&
616 test_cmp expect.log.raw actual &&
617
618 git reflog >actual &&
619 test_cmp expect.reflog.abbrev actual &&
620 git reflog --no-abbrev-commit >actual &&
621 test_cmp expect.reflog.full actual &&
622
623 git whatchanged >actual &&
624 test_cmp expect.whatchanged.abbrev actual &&
625 git whatchanged --no-abbrev-commit >actual &&
626 test_cmp expect.whatchanged.full actual
627'
628
629test_expect_success 'show added path under "--follow -M"' '
630 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
631 test_create_repo regression &&
632 (
633 cd regression &&
634 test_commit needs-another-commit &&
635 test_commit foo.bar &&
636 git log -M --follow -p foo.bar.t &&
637 git log -M --follow --stat foo.bar.t &&
638 git log -M --follow --name-only foo.bar.t
639 )
640'
641
642test_expect_success 'git log -c --follow' '
643 test_create_repo follow-c &&
644 (
645 cd follow-c &&
646 test_commit initial file original &&
647 git rm file &&
648 test_commit rename file2 original &&
649 git reset --hard initial &&
650 test_commit modify file foo &&
651 git merge -m merge rename &&
652 git log -c --follow file2
653 )
654'
655
656cat >expect <<\EOF
657* commit COMMIT_OBJECT_NAME
658|\ Merge: MERGE_PARENTS
659| | Author: A U Thor <author@example.com>
660| |
661| | Merge HEADS DESCRIPTION
662| |
663| * commit COMMIT_OBJECT_NAME
664| | Author: A U Thor <author@example.com>
665| |
666| | reach
667| | ---
668| | reach.t | 1 +
669| | 1 file changed, 1 insertion(+)
670| |
671| | diff --git a/reach.t b/reach.t
672| | new file mode 100644
673| | index 0000000..10c9591
674| | --- /dev/null
675| | +++ b/reach.t
676| | @@ -0,0 +1 @@
677| | +reach
678| |
679| \
680*-. \ commit COMMIT_OBJECT_NAME
681|\ \ \ Merge: MERGE_PARENTS
682| | | | Author: A U Thor <author@example.com>
683| | | |
684| | | | Merge HEADS DESCRIPTION
685| | | |
686| | * | commit COMMIT_OBJECT_NAME
687| | |/ Author: A U Thor <author@example.com>
688| | |
689| | | octopus-b
690| | | ---
691| | | octopus-b.t | 1 +
692| | | 1 file changed, 1 insertion(+)
693| | |
694| | | diff --git a/octopus-b.t b/octopus-b.t
695| | | new file mode 100644
696| | | index 0000000..d5fcad0
697| | | --- /dev/null
698| | | +++ b/octopus-b.t
699| | | @@ -0,0 +1 @@
700| | | +octopus-b
701| | |
702| * | commit COMMIT_OBJECT_NAME
703| |/ Author: A U Thor <author@example.com>
704| |
705| | octopus-a
706| | ---
707| | octopus-a.t | 1 +
708| | 1 file changed, 1 insertion(+)
709| |
710| | diff --git a/octopus-a.t b/octopus-a.t
711| | new file mode 100644
712| | index 0000000..11ee015
713| | --- /dev/null
714| | +++ b/octopus-a.t
715| | @@ -0,0 +1 @@
716| | +octopus-a
717| |
718* | commit COMMIT_OBJECT_NAME
719|/ Author: A U Thor <author@example.com>
720|
721| seventh
722| ---
723| seventh.t | 1 +
724| 1 file changed, 1 insertion(+)
725|
726| diff --git a/seventh.t b/seventh.t
727| new file mode 100644
728| index 0000000..9744ffc
729| --- /dev/null
730| +++ b/seventh.t
731| @@ -0,0 +1 @@
732| +seventh
733|
734* commit COMMIT_OBJECT_NAME
735|\ Merge: MERGE_PARENTS
736| | Author: A U Thor <author@example.com>
737| |
738| | Merge branch 'tangle'
739| |
740| * commit COMMIT_OBJECT_NAME
741| |\ Merge: MERGE_PARENTS
742| | | Author: A U Thor <author@example.com>
743| | |
744| | | Merge branch 'side' (early part) into tangle
745| | |
746| * | commit COMMIT_OBJECT_NAME
747| |\ \ Merge: MERGE_PARENTS
748| | | | Author: A U Thor <author@example.com>
749| | | |
750| | | | Merge branch 'master' (early part) into tangle
751| | | |
752| * | | commit COMMIT_OBJECT_NAME
753| | | | Author: A U Thor <author@example.com>
754| | | |
755| | | | tangle-a
756| | | | ---
757| | | | tangle-a | 1 +
758| | | | 1 file changed, 1 insertion(+)
759| | | |
760| | | | diff --git a/tangle-a b/tangle-a
761| | | | new file mode 100644
762| | | | index 0000000..7898192
763| | | | --- /dev/null
764| | | | +++ b/tangle-a
765| | | | @@ -0,0 +1 @@
766| | | | +a
767| | | |
768* | | | commit COMMIT_OBJECT_NAME
769|\ \ \ \ Merge: MERGE_PARENTS
770| | | | | Author: A U Thor <author@example.com>
771| | | | |
772| | | | | Merge branch 'side'
773| | | | |
774| * | | | commit COMMIT_OBJECT_NAME
775| | |_|/ Author: A U Thor <author@example.com>
776| |/| |
777| | | | side-2
778| | | | ---
779| | | | 2 | 1 +
780| | | | 1 file changed, 1 insertion(+)
781| | | |
782| | | | diff --git a/2 b/2
783| | | | new file mode 100644
784| | | | index 0000000..0cfbf08
785| | | | --- /dev/null
786| | | | +++ b/2
787| | | | @@ -0,0 +1 @@
788| | | | +2
789| | | |
790| * | | commit COMMIT_OBJECT_NAME
791| | | | Author: A U Thor <author@example.com>
792| | | |
793| | | | side-1
794| | | | ---
795| | | | 1 | 1 +
796| | | | 1 file changed, 1 insertion(+)
797| | | |
798| | | | diff --git a/1 b/1
799| | | | new file mode 100644
800| | | | index 0000000..d00491f
801| | | | --- /dev/null
802| | | | +++ b/1
803| | | | @@ -0,0 +1 @@
804| | | | +1
805| | | |
806* | | | commit COMMIT_OBJECT_NAME
807| | | | Author: A U Thor <author@example.com>
808| | | |
809| | | | Second
810| | | | ---
811| | | | one | 1 +
812| | | | 1 file changed, 1 insertion(+)
813| | | |
814| | | | diff --git a/one b/one
815| | | | new file mode 100644
816| | | | index 0000000..9a33383
817| | | | --- /dev/null
818| | | | +++ b/one
819| | | | @@ -0,0 +1 @@
820| | | | +case
821| | | |
822* | | | commit COMMIT_OBJECT_NAME
823| |_|/ Author: A U Thor <author@example.com>
824|/| |
825| | | sixth
826| | | ---
827| | | a/two | 1 -
828| | | 1 file changed, 1 deletion(-)
829| | |
830| | | diff --git a/a/two b/a/two
831| | | deleted file mode 100644
832| | | index 9245af5..0000000
833| | | --- a/a/two
834| | | +++ /dev/null
835| | | @@ -1 +0,0 @@
836| | | -ni
837| | |
838* | | commit COMMIT_OBJECT_NAME
839| | | Author: A U Thor <author@example.com>
840| | |
841| | | fifth
842| | | ---
843| | | a/two | 1 +
844| | | 1 file changed, 1 insertion(+)
845| | |
846| | | diff --git a/a/two b/a/two
847| | | new file mode 100644
848| | | index 0000000..9245af5
849| | | --- /dev/null
850| | | +++ b/a/two
851| | | @@ -0,0 +1 @@
852| | | +ni
853| | |
854* | | commit COMMIT_OBJECT_NAME
855|/ / Author: A U Thor <author@example.com>
856| |
857| | fourth
858| | ---
859| | ein | 1 +
860| | 1 file changed, 1 insertion(+)
861| |
862| | diff --git a/ein b/ein
863| | new file mode 100644
864| | index 0000000..9d7e69f
865| | --- /dev/null
866| | +++ b/ein
867| | @@ -0,0 +1 @@
868| | +ichi
869| |
870* | commit COMMIT_OBJECT_NAME
871|/ Author: A U Thor <author@example.com>
872|
873| third
874| ---
875| ichi | 1 +
876| one | 1 -
877| 2 files changed, 1 insertion(+), 1 deletion(-)
878|
879| diff --git a/ichi b/ichi
880| new file mode 100644
881| index 0000000..9d7e69f
882| --- /dev/null
883| +++ b/ichi
884| @@ -0,0 +1 @@
885| +ichi
886| diff --git a/one b/one
887| deleted file mode 100644
888| index 9d7e69f..0000000
889| --- a/one
890| +++ /dev/null
891| @@ -1 +0,0 @@
892| -ichi
893|
894* commit COMMIT_OBJECT_NAME
895| Author: A U Thor <author@example.com>
896|
897| second
898| ---
899| one | 2 +-
900| 1 file changed, 1 insertion(+), 1 deletion(-)
901|
902| diff --git a/one b/one
903| index 5626abf..9d7e69f 100644
904| --- a/one
905| +++ b/one
906| @@ -1 +1 @@
907| -one
908| +ichi
909|
910* commit COMMIT_OBJECT_NAME
911 Author: A U Thor <author@example.com>
912
913 initial
914 ---
915 one | 1 +
916 1 file changed, 1 insertion(+)
917
918 diff --git a/one b/one
919 new file mode 100644
920 index 0000000..5626abf
921 --- /dev/null
922 +++ b/one
923 @@ -0,0 +1 @@
924 +one
925EOF
926
927sanitize_output () {
928 sed -e 's/ *$//' \
929 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
930 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
931 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
932 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
933 -e 's/, 0 deletions(-)//' \
934 -e 's/, 0 insertions(+)//' \
935 -e 's/ 1 files changed, / 1 file changed, /' \
936 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
937 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
938}
939
940test_expect_success 'log --graph with diff and stats' '
941 git log --no-renames --graph --pretty=short --stat -p >actual &&
942 sanitize_output >actual.sanitized <actual &&
943 test_i18ncmp expect actual.sanitized
944'
945
946cat >expect <<\EOF
947*** * commit COMMIT_OBJECT_NAME
948*** |\ Merge: MERGE_PARENTS
949*** | | Author: A U Thor <author@example.com>
950*** | |
951*** | | Merge HEADS DESCRIPTION
952*** | |
953*** | * commit COMMIT_OBJECT_NAME
954*** | | Author: A U Thor <author@example.com>
955*** | |
956*** | | reach
957*** | | ---
958*** | | reach.t | 1 +
959*** | | 1 file changed, 1 insertion(+)
960*** | |
961*** | | diff --git a/reach.t b/reach.t
962*** | | new file mode 100644
963*** | | index 0000000..10c9591
964*** | | --- /dev/null
965*** | | +++ b/reach.t
966*** | | @@ -0,0 +1 @@
967*** | | +reach
968*** | |
969*** | \
970*** *-. \ commit COMMIT_OBJECT_NAME
971*** |\ \ \ Merge: MERGE_PARENTS
972*** | | | | Author: A U Thor <author@example.com>
973*** | | | |
974*** | | | | Merge HEADS DESCRIPTION
975*** | | | |
976*** | | * | commit COMMIT_OBJECT_NAME
977*** | | |/ Author: A U Thor <author@example.com>
978*** | | |
979*** | | | octopus-b
980*** | | | ---
981*** | | | octopus-b.t | 1 +
982*** | | | 1 file changed, 1 insertion(+)
983*** | | |
984*** | | | diff --git a/octopus-b.t b/octopus-b.t
985*** | | | new file mode 100644
986*** | | | index 0000000..d5fcad0
987*** | | | --- /dev/null
988*** | | | +++ b/octopus-b.t
989*** | | | @@ -0,0 +1 @@
990*** | | | +octopus-b
991*** | | |
992*** | * | commit COMMIT_OBJECT_NAME
993*** | |/ Author: A U Thor <author@example.com>
994*** | |
995*** | | octopus-a
996*** | | ---
997*** | | octopus-a.t | 1 +
998*** | | 1 file changed, 1 insertion(+)
999*** | |
1000*** | | diff --git a/octopus-a.t b/octopus-a.t
1001*** | | new file mode 100644
1002*** | | index 0000000..11ee015
1003*** | | --- /dev/null
1004*** | | +++ b/octopus-a.t
1005*** | | @@ -0,0 +1 @@
1006*** | | +octopus-a
1007*** | |
1008*** * | commit COMMIT_OBJECT_NAME
1009*** |/ Author: A U Thor <author@example.com>
1010*** |
1011*** | seventh
1012*** | ---
1013*** | seventh.t | 1 +
1014*** | 1 file changed, 1 insertion(+)
1015*** |
1016*** | diff --git a/seventh.t b/seventh.t
1017*** | new file mode 100644
1018*** | index 0000000..9744ffc
1019*** | --- /dev/null
1020*** | +++ b/seventh.t
1021*** | @@ -0,0 +1 @@
1022*** | +seventh
1023*** |
1024*** * commit COMMIT_OBJECT_NAME
1025*** |\ Merge: MERGE_PARENTS
1026*** | | Author: A U Thor <author@example.com>
1027*** | |
1028*** | | Merge branch 'tangle'
1029*** | |
1030*** | * commit COMMIT_OBJECT_NAME
1031*** | |\ Merge: MERGE_PARENTS
1032*** | | | Author: A U Thor <author@example.com>
1033*** | | |
1034*** | | | Merge branch 'side' (early part) into tangle
1035*** | | |
1036*** | * | commit COMMIT_OBJECT_NAME
1037*** | |\ \ Merge: MERGE_PARENTS
1038*** | | | | Author: A U Thor <author@example.com>
1039*** | | | |
1040*** | | | | Merge branch 'master' (early part) into tangle
1041*** | | | |
1042*** | * | | commit COMMIT_OBJECT_NAME
1043*** | | | | Author: A U Thor <author@example.com>
1044*** | | | |
1045*** | | | | tangle-a
1046*** | | | | ---
1047*** | | | | tangle-a | 1 +
1048*** | | | | 1 file changed, 1 insertion(+)
1049*** | | | |
1050*** | | | | diff --git a/tangle-a b/tangle-a
1051*** | | | | new file mode 100644
1052*** | | | | index 0000000..7898192
1053*** | | | | --- /dev/null
1054*** | | | | +++ b/tangle-a
1055*** | | | | @@ -0,0 +1 @@
1056*** | | | | +a
1057*** | | | |
1058*** * | | | commit COMMIT_OBJECT_NAME
1059*** |\ \ \ \ Merge: MERGE_PARENTS
1060*** | | | | | Author: A U Thor <author@example.com>
1061*** | | | | |
1062*** | | | | | Merge branch 'side'
1063*** | | | | |
1064*** | * | | | commit COMMIT_OBJECT_NAME
1065*** | | |_|/ Author: A U Thor <author@example.com>
1066*** | |/| |
1067*** | | | | side-2
1068*** | | | | ---
1069*** | | | | 2 | 1 +
1070*** | | | | 1 file changed, 1 insertion(+)
1071*** | | | |
1072*** | | | | diff --git a/2 b/2
1073*** | | | | new file mode 100644
1074*** | | | | index 0000000..0cfbf08
1075*** | | | | --- /dev/null
1076*** | | | | +++ b/2
1077*** | | | | @@ -0,0 +1 @@
1078*** | | | | +2
1079*** | | | |
1080*** | * | | commit COMMIT_OBJECT_NAME
1081*** | | | | Author: A U Thor <author@example.com>
1082*** | | | |
1083*** | | | | side-1
1084*** | | | | ---
1085*** | | | | 1 | 1 +
1086*** | | | | 1 file changed, 1 insertion(+)
1087*** | | | |
1088*** | | | | diff --git a/1 b/1
1089*** | | | | new file mode 100644
1090*** | | | | index 0000000..d00491f
1091*** | | | | --- /dev/null
1092*** | | | | +++ b/1
1093*** | | | | @@ -0,0 +1 @@
1094*** | | | | +1
1095*** | | | |
1096*** * | | | commit COMMIT_OBJECT_NAME
1097*** | | | | Author: A U Thor <author@example.com>
1098*** | | | |
1099*** | | | | Second
1100*** | | | | ---
1101*** | | | | one | 1 +
1102*** | | | | 1 file changed, 1 insertion(+)
1103*** | | | |
1104*** | | | | diff --git a/one b/one
1105*** | | | | new file mode 100644
1106*** | | | | index 0000000..9a33383
1107*** | | | | --- /dev/null
1108*** | | | | +++ b/one
1109*** | | | | @@ -0,0 +1 @@
1110*** | | | | +case
1111*** | | | |
1112*** * | | | commit COMMIT_OBJECT_NAME
1113*** | |_|/ Author: A U Thor <author@example.com>
1114*** |/| |
1115*** | | | sixth
1116*** | | | ---
1117*** | | | a/two | 1 -
1118*** | | | 1 file changed, 1 deletion(-)
1119*** | | |
1120*** | | | diff --git a/a/two b/a/two
1121*** | | | deleted file mode 100644
1122*** | | | index 9245af5..0000000
1123*** | | | --- a/a/two
1124*** | | | +++ /dev/null
1125*** | | | @@ -1 +0,0 @@
1126*** | | | -ni
1127*** | | |
1128*** * | | commit COMMIT_OBJECT_NAME
1129*** | | | Author: A U Thor <author@example.com>
1130*** | | |
1131*** | | | fifth
1132*** | | | ---
1133*** | | | a/two | 1 +
1134*** | | | 1 file changed, 1 insertion(+)
1135*** | | |
1136*** | | | diff --git a/a/two b/a/two
1137*** | | | new file mode 100644
1138*** | | | index 0000000..9245af5
1139*** | | | --- /dev/null
1140*** | | | +++ b/a/two
1141*** | | | @@ -0,0 +1 @@
1142*** | | | +ni
1143*** | | |
1144*** * | | commit COMMIT_OBJECT_NAME
1145*** |/ / Author: A U Thor <author@example.com>
1146*** | |
1147*** | | fourth
1148*** | | ---
1149*** | | ein | 1 +
1150*** | | 1 file changed, 1 insertion(+)
1151*** | |
1152*** | | diff --git a/ein b/ein
1153*** | | new file mode 100644
1154*** | | index 0000000..9d7e69f
1155*** | | --- /dev/null
1156*** | | +++ b/ein
1157*** | | @@ -0,0 +1 @@
1158*** | | +ichi
1159*** | |
1160*** * | commit COMMIT_OBJECT_NAME
1161*** |/ Author: A U Thor <author@example.com>
1162*** |
1163*** | third
1164*** | ---
1165*** | ichi | 1 +
1166*** | one | 1 -
1167*** | 2 files changed, 1 insertion(+), 1 deletion(-)
1168*** |
1169*** | diff --git a/ichi b/ichi
1170*** | new file mode 100644
1171*** | index 0000000..9d7e69f
1172*** | --- /dev/null
1173*** | +++ b/ichi
1174*** | @@ -0,0 +1 @@
1175*** | +ichi
1176*** | diff --git a/one b/one
1177*** | deleted file mode 100644
1178*** | index 9d7e69f..0000000
1179*** | --- a/one
1180*** | +++ /dev/null
1181*** | @@ -1 +0,0 @@
1182*** | -ichi
1183*** |
1184*** * commit COMMIT_OBJECT_NAME
1185*** | Author: A U Thor <author@example.com>
1186*** |
1187*** | second
1188*** | ---
1189*** | one | 2 +-
1190*** | 1 file changed, 1 insertion(+), 1 deletion(-)
1191*** |
1192*** | diff --git a/one b/one
1193*** | index 5626abf..9d7e69f 100644
1194*** | --- a/one
1195*** | +++ b/one
1196*** | @@ -1 +1 @@
1197*** | -one
1198*** | +ichi
1199*** |
1200*** * commit COMMIT_OBJECT_NAME
1201*** Author: A U Thor <author@example.com>
1202***
1203*** initial
1204*** ---
1205*** one | 1 +
1206*** 1 file changed, 1 insertion(+)
1207***
1208*** diff --git a/one b/one
1209*** new file mode 100644
1210*** index 0000000..5626abf
1211*** --- /dev/null
1212*** +++ b/one
1213*** @@ -0,0 +1 @@
1214*** +one
1215EOF
1216
1217test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1218 git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1219 sanitize_output >actual.sanitized <actual &&
1220 test_i18ncmp expect actual.sanitized
1221'
1222
1223cat >expect <<-\EOF
1224* reach
1225|
1226| A reach.t
1227* Merge branch 'tangle'
1228* Merge branch 'side'
1229|\
1230| * side-2
1231|
1232| A 2
1233* Second
1234|
1235| A one
1236* sixth
1237
1238 D a/two
1239EOF
1240
1241test_expect_success 'log --graph with --name-status' '
1242 git log --graph --format=%s --name-status tangle..reach >actual &&
1243 sanitize_output <actual >actual.sanitized &&
1244 test_cmp expect actual.sanitized
1245'
1246
1247cat >expect <<-\EOF
1248* reach
1249|
1250| reach.t
1251* Merge branch 'tangle'
1252* Merge branch 'side'
1253|\
1254| * side-2
1255|
1256| 2
1257* Second
1258|
1259| one
1260* sixth
1261
1262 a/two
1263EOF
1264
1265test_expect_success 'log --graph with --name-only' '
1266 git log --graph --format=%s --name-only tangle..reach >actual &&
1267 sanitize_output <actual >actual.sanitized &&
1268 test_cmp expect actual.sanitized
1269'
1270
1271test_expect_success 'dotdot is a parent directory' '
1272 mkdir -p a/b &&
1273 ( echo sixth && echo fifth ) >expect &&
1274 ( cd a/b && git log --format=%s .. ) >actual &&
1275 test_cmp expect actual
1276'
1277
1278test_expect_success GPG 'setup signed branch' '
1279 test_when_finished "git reset --hard && git checkout master" &&
1280 git checkout -b signed master &&
1281 echo foo >foo &&
1282 git add foo &&
1283 git commit -S -m signed_commit
1284'
1285
1286test_expect_success GPG 'log --graph --show-signature' '
1287 git log --graph --show-signature -n1 signed >actual &&
1288 grep "^| gpg: Signature made" actual &&
1289 grep "^| gpg: Good signature" actual
1290'
1291
1292test_expect_success GPG 'log --graph --show-signature for merged tag' '
1293 test_when_finished "git reset --hard && git checkout master" &&
1294 git checkout -b plain master &&
1295 echo aaa >bar &&
1296 git add bar &&
1297 git commit -m bar_commit &&
1298 git checkout -b tagged master &&
1299 echo bbb >baz &&
1300 git add baz &&
1301 git commit -m baz_commit &&
1302 git tag -s -m signed_tag_msg signed_tag &&
1303 git checkout plain &&
1304 git merge --no-ff -m msg signed_tag &&
1305 git log --graph --show-signature -n1 plain >actual &&
1306 grep "^|\\\ merged tag" actual &&
1307 grep "^| | gpg: Signature made" actual &&
1308 grep "^| | gpg: Good signature" actual
1309'
1310
1311test_expect_success GPG '--no-show-signature overrides --show-signature' '
1312 git log -1 --show-signature --no-show-signature signed >actual &&
1313 ! grep "^gpg:" actual
1314'
1315
1316test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1317 test_config log.showsignature true &&
1318 git log -1 signed >actual &&
1319 grep "gpg: Signature made" actual &&
1320 grep "gpg: Good signature" actual
1321'
1322
1323test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1324 test_config log.showsignature true &&
1325 git log -1 --no-show-signature signed >actual &&
1326 ! grep "^gpg:" actual
1327'
1328
1329test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1330 test_config log.showsignature false &&
1331 git log -1 --show-signature signed >actual &&
1332 grep "gpg: Signature made" actual &&
1333 grep "gpg: Good signature" actual
1334'
1335
1336test_expect_success 'log --graph --no-walk is forbidden' '
1337 test_must_fail git log --graph --no-walk
1338'
1339
1340test_expect_success 'log diagnoses bogus HEAD' '
1341 git init empty &&
1342 test_must_fail git -C empty log 2>stderr &&
1343 test_i18ngrep does.not.have.any.commits stderr &&
1344 echo 1234abcd >empty/.git/refs/heads/master &&
1345 test_must_fail git -C empty log 2>stderr &&
1346 test_i18ngrep broken stderr &&
1347 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1348 test_must_fail git -C empty log 2>stderr &&
1349 test_i18ngrep broken stderr &&
1350 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1351 test_i18ngrep broken stderr
1352'
1353
1354test_expect_success 'set up --source tests' '
1355 git checkout --orphan source-a &&
1356 test_commit one &&
1357 test_commit two &&
1358 git checkout -b source-b HEAD^ &&
1359 test_commit three
1360'
1361
1362test_expect_success 'log --source paints branch names' '
1363 cat >expect <<-\EOF &&
1364 09e12a9 source-b three
1365 8e393e1 source-a two
1366 1ac6c77 source-b one
1367 EOF
1368 git log --oneline --source source-a source-b >actual &&
1369 test_cmp expect actual
1370'
1371
1372test_expect_success 'log --source paints tag names' '
1373 git tag -m tagged source-tag &&
1374 cat >expect <<-\EOF &&
1375 09e12a9 source-tag three
1376 8e393e1 source-a two
1377 1ac6c77 source-tag one
1378 EOF
1379 git log --oneline --source source-tag source-a >actual &&
1380 test_cmp expect actual
1381'
1382
1383test_expect_success 'log --source paints symmetric ranges' '
1384 cat >expect <<-\EOF &&
1385 09e12a9 source-b three
1386 8e393e1 source-a two
1387 EOF
1388 git log --oneline --source source-a...source-b >actual &&
1389 test_cmp expect actual
1390'
1391
1392test_done