1#!/bin/sh
2
3test_description='git log'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY/lib-gpg.sh"
7
8test_expect_success setup '
9
10 echo one >one &&
11 git add one &&
12 test_tick &&
13 git commit -m initial &&
14
15 echo ichi >one &&
16 git add one &&
17 test_tick &&
18 git commit -m second &&
19
20 git mv one ichi &&
21 test_tick &&
22 git commit -m third &&
23
24 cp ichi ein &&
25 git add ein &&
26 test_tick &&
27 git commit -m fourth &&
28
29 mkdir a &&
30 echo ni >a/two &&
31 git add a/two &&
32 test_tick &&
33 git commit -m fifth &&
34
35 git rm a/two &&
36 test_tick &&
37 git commit -m sixth
38
39'
40
41printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
42test_expect_success 'pretty' '
43
44 git log --pretty="format:%s" > actual &&
45 test_cmp expect actual
46'
47
48printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
49test_expect_success 'pretty (tformat)' '
50
51 git log --pretty="tformat:%s" > actual &&
52 test_cmp expect actual
53'
54
55test_expect_success 'pretty (shortcut)' '
56
57 git log --pretty="%s" > actual &&
58 test_cmp expect actual
59'
60
61test_expect_success 'format' '
62
63 git log --format="%s" > actual &&
64 test_cmp expect actual
65'
66
67cat > expect << EOF
68 This is
69 the sixth
70 commit.
71 This is
72 the fifth
73 commit.
74EOF
75
76test_expect_success 'format %w(11,1,2)' '
77
78 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
79 test_cmp expect actual
80'
81
82test_expect_success 'format %w(,1,2)' '
83
84 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
85 test_cmp expect actual
86'
87
88cat > expect << EOF
89804a787 sixth
90394ef78 fifth
915d31159 fourth
922fbe8c0 third
93f7dab8e second
943a2fdcb initial
95EOF
96test_expect_success 'oneline' '
97
98 git log --oneline > actual &&
99 test_cmp expect actual
100'
101
102test_expect_success 'diff-filter=A' '
103
104 git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
105 git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
106 printf "fifth\nfourth\nthird\ninitial" > expect &&
107 test_cmp expect actual &&
108 test_cmp expect actual-separate
109
110'
111
112test_expect_success 'diff-filter=M' '
113
114 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
115 expect=$(echo second) &&
116 verbose test "$actual" = "$expect"
117
118'
119
120test_expect_success 'diff-filter=D' '
121
122 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
123 expect=$(echo sixth ; echo third) &&
124 verbose test "$actual" = "$expect"
125
126'
127
128test_expect_success 'diff-filter=R' '
129
130 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
131 expect=$(echo third) &&
132 verbose test "$actual" = "$expect"
133
134'
135
136test_expect_success 'diff-filter=C' '
137
138 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
139 expect=$(echo fourth) &&
140 verbose test "$actual" = "$expect"
141
142'
143
144test_expect_success 'git log --follow' '
145
146 actual=$(git log --follow --pretty="format:%s" ichi) &&
147 expect=$(echo third ; echo second ; echo initial) &&
148 verbose test "$actual" = "$expect"
149'
150
151test_expect_success 'git config log.follow works like --follow' '
152 test_config log.follow true &&
153 actual=$(git log --pretty="format:%s" ichi) &&
154 expect=$(echo third ; echo second ; echo initial) &&
155 verbose test "$actual" = "$expect"
156'
157
158test_expect_success 'git config log.follow does not die with multiple paths' '
159 test_config log.follow true &&
160 git log --pretty="format:%s" ichi ein
161'
162
163test_expect_success 'git config log.follow does not die with no paths' '
164 test_config log.follow true &&
165 git log --
166'
167
168test_expect_success 'git config log.follow is overridden by --no-follow' '
169 test_config log.follow true &&
170 actual=$(git log --no-follow --pretty="format:%s" ichi) &&
171 expect="third" &&
172 verbose test "$actual" = "$expect"
173'
174
175cat > expect << EOF
176804a787 sixth
177394ef78 fifth
1785d31159 fourth
179EOF
180test_expect_success 'git log --no-walk <commits> sorts by commit time' '
181 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
182 test_cmp expect actual
183'
184
185test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
186 git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
187 test_cmp expect actual
188'
189
190cat > expect << EOF
1915d31159 fourth
192804a787 sixth
193394ef78 fifth
194EOF
195test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
196 git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
197 test_cmp expect actual
198'
199
200test_expect_success 'git show <commits> leaves list of commits as given' '
201 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
202 test_cmp expect actual
203'
204
205test_expect_success 'setup case sensitivity tests' '
206 echo case >one &&
207 test_tick &&
208 git add one &&
209 git commit -a -m Second
210'
211
212test_expect_success 'log --grep' '
213 echo second >expect &&
214 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
215 test_cmp expect actual
216'
217
218cat > expect << EOF
219second
220initial
221EOF
222test_expect_success 'log --invert-grep --grep' '
223 git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
224 test_cmp expect actual
225'
226
227test_expect_success 'log --invert-grep --grep -i' '
228 echo initial >expect &&
229 git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
230 test_cmp expect actual
231'
232
233test_expect_success 'log --grep option parsing' '
234 echo second >expect &&
235 git log -1 --pretty="tformat:%s" --grep sec >actual &&
236 test_cmp expect actual &&
237 test_must_fail git log -1 --pretty="tformat:%s" --grep
238'
239
240test_expect_success 'log -i --grep' '
241 echo Second >expect &&
242 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
243 test_cmp expect actual
244'
245
246test_expect_success 'log --grep -i' '
247 echo Second >expect &&
248 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
249 test_cmp expect actual
250'
251
252test_expect_success 'log -F -E --grep=<ere> uses ere' '
253 echo second >expect &&
254 git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
255 test_cmp expect actual
256'
257
258cat > expect <<EOF
259* Second
260* sixth
261* fifth
262* fourth
263* third
264* second
265* initial
266EOF
267
268test_expect_success 'simple log --graph' '
269 git log --graph --pretty=tformat:%s >actual &&
270 test_cmp expect actual
271'
272
273test_expect_success 'set up merge history' '
274 git checkout -b side HEAD~4 &&
275 test_commit side-1 1 1 &&
276 test_commit side-2 2 2 &&
277 git checkout master &&
278 git merge side
279'
280
281cat > expect <<\EOF
282* Merge branch 'side'
283|\
284| * side-2
285| * side-1
286* | Second
287* | sixth
288* | fifth
289* | fourth
290|/
291* third
292* second
293* initial
294EOF
295
296test_expect_success 'log --graph with merge' '
297 git log --graph --date-order --pretty=tformat:%s |
298 sed "s/ *\$//" >actual &&
299 test_cmp expect actual
300'
301
302test_expect_success 'log --raw --graph -m with merge' '
303 git log --raw --graph --oneline -m master | head -n 500 >actual &&
304 grep "initial" actual
305'
306
307test_expect_success 'diff-tree --graph' '
308 git diff-tree --graph master^ | head -n 500 >actual &&
309 grep "one" actual
310'
311
312cat > expect <<\EOF
313* commit master
314|\ Merge: A B
315| | Author: A U Thor <author@example.com>
316| |
317| | Merge branch 'side'
318| |
319| * commit side
320| | Author: A U Thor <author@example.com>
321| |
322| | side-2
323| |
324| * commit tags/side-1
325| | Author: A U Thor <author@example.com>
326| |
327| | side-1
328| |
329* | commit master~1
330| | Author: A U Thor <author@example.com>
331| |
332| | Second
333| |
334* | commit master~2
335| | Author: A U Thor <author@example.com>
336| |
337| | sixth
338| |
339* | commit master~3
340| | Author: A U Thor <author@example.com>
341| |
342| | fifth
343| |
344* | commit master~4
345|/ Author: A U Thor <author@example.com>
346|
347| fourth
348|
349* commit tags/side-1~1
350| Author: A U Thor <author@example.com>
351|
352| third
353|
354* commit tags/side-1~2
355| Author: A U Thor <author@example.com>
356|
357| second
358|
359* commit tags/side-1~3
360 Author: A U Thor <author@example.com>
361
362 initial
363EOF
364
365test_expect_success 'log --graph with full output' '
366 git log --graph --date-order --pretty=short |
367 git name-rev --name-only --stdin |
368 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
369 test_cmp expect actual
370'
371
372test_expect_success 'set up more tangled history' '
373 git checkout -b tangle HEAD~6 &&
374 test_commit tangle-a tangle-a a &&
375 git merge master~3 &&
376 git merge side~1 &&
377 git checkout master &&
378 git merge tangle &&
379 git checkout -b reach &&
380 test_commit reach &&
381 git checkout master &&
382 git checkout -b octopus-a &&
383 test_commit octopus-a &&
384 git checkout master &&
385 git checkout -b octopus-b &&
386 test_commit octopus-b &&
387 git checkout master &&
388 test_commit seventh &&
389 git merge octopus-a octopus-b &&
390 git merge reach
391'
392
393cat > expect <<\EOF
394* Merge tag 'reach'
395|\
396| \
397| \
398*-. \ Merge tags 'octopus-a' and 'octopus-b'
399|\ \ \
400* | | | seventh
401| | * | octopus-b
402| |/ /
403|/| |
404| * | octopus-a
405|/ /
406| * reach
407|/
408* Merge branch 'tangle'
409|\
410| * Merge branch 'side' (early part) into tangle
411| |\
412| * \ Merge branch 'master' (early part) into tangle
413| |\ \
414| * | | tangle-a
415* | | | Merge branch 'side'
416|\ \ \ \
417| * | | | side-2
418| | |_|/
419| |/| |
420| * | | side-1
421* | | | Second
422* | | | sixth
423| |_|/
424|/| |
425* | | fifth
426* | | fourth
427|/ /
428* | third
429|/
430* second
431* initial
432EOF
433
434test_expect_success 'log --graph with merge' '
435 git log --graph --date-order --pretty=tformat:%s |
436 sed "s/ *\$//" >actual &&
437 test_cmp expect actual
438'
439
440test_expect_success 'log.decorate configuration' '
441 git log --oneline >expect.none &&
442 git log --oneline --decorate >expect.short &&
443 git log --oneline --decorate=full >expect.full &&
444
445 echo "[log] decorate" >>.git/config &&
446 git log --oneline >actual &&
447 test_cmp expect.short actual &&
448
449 test_config log.decorate true &&
450 git log --oneline >actual &&
451 test_cmp expect.short actual &&
452 git log --oneline --decorate=full >actual &&
453 test_cmp expect.full actual &&
454 git log --oneline --decorate=no >actual &&
455 test_cmp expect.none actual &&
456
457 test_config log.decorate no &&
458 git log --oneline >actual &&
459 test_cmp expect.none actual &&
460 git log --oneline --decorate >actual &&
461 test_cmp expect.short actual &&
462 git log --oneline --decorate=full >actual &&
463 test_cmp expect.full actual &&
464
465 test_config log.decorate 1 &&
466 git log --oneline >actual &&
467 test_cmp expect.short actual &&
468 git log --oneline --decorate=full >actual &&
469 test_cmp expect.full actual &&
470 git log --oneline --decorate=no >actual &&
471 test_cmp expect.none actual &&
472
473 test_config log.decorate short &&
474 git log --oneline >actual &&
475 test_cmp expect.short actual &&
476 git log --oneline --no-decorate >actual &&
477 test_cmp expect.none actual &&
478 git log --oneline --decorate=full >actual &&
479 test_cmp expect.full actual &&
480
481 test_config log.decorate full &&
482 git log --oneline >actual &&
483 test_cmp expect.full actual &&
484 git log --oneline --no-decorate >actual &&
485 test_cmp expect.none actual &&
486 git log --oneline --decorate >actual &&
487 test_cmp expect.short actual &&
488
489 test_unconfig log.decorate &&
490 git log --pretty=raw >expect.raw &&
491 test_config log.decorate full &&
492 git log --pretty=raw >actual &&
493 test_cmp expect.raw actual
494
495'
496
497test_expect_success 'reflog is expected format' '
498 git log -g --abbrev-commit --pretty=oneline >expect &&
499 git reflog >actual &&
500 test_cmp expect actual
501'
502
503test_expect_success 'whatchanged is expected format' '
504 git log --no-merges --raw >expect &&
505 git whatchanged >actual &&
506 test_cmp expect actual
507'
508
509test_expect_success 'log.abbrevCommit configuration' '
510 git log --abbrev-commit >expect.log.abbrev &&
511 git log --no-abbrev-commit >expect.log.full &&
512 git log --pretty=raw >expect.log.raw &&
513 git reflog --abbrev-commit >expect.reflog.abbrev &&
514 git reflog --no-abbrev-commit >expect.reflog.full &&
515 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
516 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
517
518 test_config log.abbrevCommit true &&
519
520 git log >actual &&
521 test_cmp expect.log.abbrev actual &&
522 git log --no-abbrev-commit >actual &&
523 test_cmp expect.log.full actual &&
524
525 git log --pretty=raw >actual &&
526 test_cmp expect.log.raw actual &&
527
528 git reflog >actual &&
529 test_cmp expect.reflog.abbrev actual &&
530 git reflog --no-abbrev-commit >actual &&
531 test_cmp expect.reflog.full actual &&
532
533 git whatchanged >actual &&
534 test_cmp expect.whatchanged.abbrev actual &&
535 git whatchanged --no-abbrev-commit >actual &&
536 test_cmp expect.whatchanged.full actual
537'
538
539test_expect_success 'show added path under "--follow -M"' '
540 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
541 test_create_repo regression &&
542 (
543 cd regression &&
544 test_commit needs-another-commit &&
545 test_commit foo.bar &&
546 git log -M --follow -p foo.bar.t &&
547 git log -M --follow --stat foo.bar.t &&
548 git log -M --follow --name-only foo.bar.t
549 )
550'
551
552test_expect_success 'git log -c --follow' '
553 test_create_repo follow-c &&
554 (
555 cd follow-c &&
556 test_commit initial file original &&
557 git rm file &&
558 test_commit rename file2 original &&
559 git reset --hard initial &&
560 test_commit modify file foo &&
561 git merge -m merge rename &&
562 git log -c --follow file2
563 )
564'
565
566cat >expect <<\EOF
567* commit COMMIT_OBJECT_NAME
568|\ Merge: MERGE_PARENTS
569| | Author: A U Thor <author@example.com>
570| |
571| | Merge HEADS DESCRIPTION
572| |
573| * commit COMMIT_OBJECT_NAME
574| | Author: A U Thor <author@example.com>
575| |
576| | reach
577| | ---
578| | reach.t | 1 +
579| | 1 file changed, 1 insertion(+)
580| |
581| | diff --git a/reach.t b/reach.t
582| | new file mode 100644
583| | index 0000000..10c9591
584| | --- /dev/null
585| | +++ b/reach.t
586| | @@ -0,0 +1 @@
587| | +reach
588| |
589| \
590*-. \ commit COMMIT_OBJECT_NAME
591|\ \ \ Merge: MERGE_PARENTS
592| | | | Author: A U Thor <author@example.com>
593| | | |
594| | | | Merge HEADS DESCRIPTION
595| | | |
596| | * | commit COMMIT_OBJECT_NAME
597| | |/ Author: A U Thor <author@example.com>
598| | |
599| | | octopus-b
600| | | ---
601| | | octopus-b.t | 1 +
602| | | 1 file changed, 1 insertion(+)
603| | |
604| | | diff --git a/octopus-b.t b/octopus-b.t
605| | | new file mode 100644
606| | | index 0000000..d5fcad0
607| | | --- /dev/null
608| | | +++ b/octopus-b.t
609| | | @@ -0,0 +1 @@
610| | | +octopus-b
611| | |
612| * | commit COMMIT_OBJECT_NAME
613| |/ Author: A U Thor <author@example.com>
614| |
615| | octopus-a
616| | ---
617| | octopus-a.t | 1 +
618| | 1 file changed, 1 insertion(+)
619| |
620| | diff --git a/octopus-a.t b/octopus-a.t
621| | new file mode 100644
622| | index 0000000..11ee015
623| | --- /dev/null
624| | +++ b/octopus-a.t
625| | @@ -0,0 +1 @@
626| | +octopus-a
627| |
628* | commit COMMIT_OBJECT_NAME
629|/ Author: A U Thor <author@example.com>
630|
631| seventh
632| ---
633| seventh.t | 1 +
634| 1 file changed, 1 insertion(+)
635|
636| diff --git a/seventh.t b/seventh.t
637| new file mode 100644
638| index 0000000..9744ffc
639| --- /dev/null
640| +++ b/seventh.t
641| @@ -0,0 +1 @@
642| +seventh
643|
644* commit COMMIT_OBJECT_NAME
645|\ Merge: MERGE_PARENTS
646| | Author: A U Thor <author@example.com>
647| |
648| | Merge branch 'tangle'
649| |
650| * commit COMMIT_OBJECT_NAME
651| |\ Merge: MERGE_PARENTS
652| | | Author: A U Thor <author@example.com>
653| | |
654| | | Merge branch 'side' (early part) into tangle
655| | |
656| * | commit COMMIT_OBJECT_NAME
657| |\ \ Merge: MERGE_PARENTS
658| | | | Author: A U Thor <author@example.com>
659| | | |
660| | | | Merge branch 'master' (early part) into tangle
661| | | |
662| * | | commit COMMIT_OBJECT_NAME
663| | | | Author: A U Thor <author@example.com>
664| | | |
665| | | | tangle-a
666| | | | ---
667| | | | tangle-a | 1 +
668| | | | 1 file changed, 1 insertion(+)
669| | | |
670| | | | diff --git a/tangle-a b/tangle-a
671| | | | new file mode 100644
672| | | | index 0000000..7898192
673| | | | --- /dev/null
674| | | | +++ b/tangle-a
675| | | | @@ -0,0 +1 @@
676| | | | +a
677| | | |
678* | | | commit COMMIT_OBJECT_NAME
679|\ \ \ \ Merge: MERGE_PARENTS
680| | | | | Author: A U Thor <author@example.com>
681| | | | |
682| | | | | Merge branch 'side'
683| | | | |
684| * | | | commit COMMIT_OBJECT_NAME
685| | |_|/ Author: A U Thor <author@example.com>
686| |/| |
687| | | | side-2
688| | | | ---
689| | | | 2 | 1 +
690| | | | 1 file changed, 1 insertion(+)
691| | | |
692| | | | diff --git a/2 b/2
693| | | | new file mode 100644
694| | | | index 0000000..0cfbf08
695| | | | --- /dev/null
696| | | | +++ b/2
697| | | | @@ -0,0 +1 @@
698| | | | +2
699| | | |
700| * | | commit COMMIT_OBJECT_NAME
701| | | | Author: A U Thor <author@example.com>
702| | | |
703| | | | side-1
704| | | | ---
705| | | | 1 | 1 +
706| | | | 1 file changed, 1 insertion(+)
707| | | |
708| | | | diff --git a/1 b/1
709| | | | new file mode 100644
710| | | | index 0000000..d00491f
711| | | | --- /dev/null
712| | | | +++ b/1
713| | | | @@ -0,0 +1 @@
714| | | | +1
715| | | |
716* | | | commit COMMIT_OBJECT_NAME
717| | | | Author: A U Thor <author@example.com>
718| | | |
719| | | | Second
720| | | | ---
721| | | | one | 1 +
722| | | | 1 file changed, 1 insertion(+)
723| | | |
724| | | | diff --git a/one b/one
725| | | | new file mode 100644
726| | | | index 0000000..9a33383
727| | | | --- /dev/null
728| | | | +++ b/one
729| | | | @@ -0,0 +1 @@
730| | | | +case
731| | | |
732* | | | commit COMMIT_OBJECT_NAME
733| |_|/ Author: A U Thor <author@example.com>
734|/| |
735| | | sixth
736| | | ---
737| | | a/two | 1 -
738| | | 1 file changed, 1 deletion(-)
739| | |
740| | | diff --git a/a/two b/a/two
741| | | deleted file mode 100644
742| | | index 9245af5..0000000
743| | | --- a/a/two
744| | | +++ /dev/null
745| | | @@ -1 +0,0 @@
746| | | -ni
747| | |
748* | | commit COMMIT_OBJECT_NAME
749| | | Author: A U Thor <author@example.com>
750| | |
751| | | fifth
752| | | ---
753| | | a/two | 1 +
754| | | 1 file changed, 1 insertion(+)
755| | |
756| | | diff --git a/a/two b/a/two
757| | | new file mode 100644
758| | | index 0000000..9245af5
759| | | --- /dev/null
760| | | +++ b/a/two
761| | | @@ -0,0 +1 @@
762| | | +ni
763| | |
764* | | commit COMMIT_OBJECT_NAME
765|/ / Author: A U Thor <author@example.com>
766| |
767| | fourth
768| | ---
769| | ein | 1 +
770| | 1 file changed, 1 insertion(+)
771| |
772| | diff --git a/ein b/ein
773| | new file mode 100644
774| | index 0000000..9d7e69f
775| | --- /dev/null
776| | +++ b/ein
777| | @@ -0,0 +1 @@
778| | +ichi
779| |
780* | commit COMMIT_OBJECT_NAME
781|/ Author: A U Thor <author@example.com>
782|
783| third
784| ---
785| ichi | 1 +
786| one | 1 -
787| 2 files changed, 1 insertion(+), 1 deletion(-)
788|
789| diff --git a/ichi b/ichi
790| new file mode 100644
791| index 0000000..9d7e69f
792| --- /dev/null
793| +++ b/ichi
794| @@ -0,0 +1 @@
795| +ichi
796| diff --git a/one b/one
797| deleted file mode 100644
798| index 9d7e69f..0000000
799| --- a/one
800| +++ /dev/null
801| @@ -1 +0,0 @@
802| -ichi
803|
804* commit COMMIT_OBJECT_NAME
805| Author: A U Thor <author@example.com>
806|
807| second
808| ---
809| one | 2 +-
810| 1 file changed, 1 insertion(+), 1 deletion(-)
811|
812| diff --git a/one b/one
813| index 5626abf..9d7e69f 100644
814| --- a/one
815| +++ b/one
816| @@ -1 +1 @@
817| -one
818| +ichi
819|
820* commit COMMIT_OBJECT_NAME
821 Author: A U Thor <author@example.com>
822
823 initial
824 ---
825 one | 1 +
826 1 file changed, 1 insertion(+)
827
828 diff --git a/one b/one
829 new file mode 100644
830 index 0000000..5626abf
831 --- /dev/null
832 +++ b/one
833 @@ -0,0 +1 @@
834 +one
835EOF
836
837sanitize_output () {
838 sed -e 's/ *$//' \
839 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
840 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
841 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
842 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
843 -e 's/, 0 deletions(-)//' \
844 -e 's/, 0 insertions(+)//' \
845 -e 's/ 1 files changed, / 1 file changed, /' \
846 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
847 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
848}
849
850test_expect_success 'log --graph with diff and stats' '
851 git log --no-renames --graph --pretty=short --stat -p >actual &&
852 sanitize_output >actual.sanitized <actual &&
853 test_i18ncmp expect actual.sanitized
854'
855
856test_expect_success 'dotdot is a parent directory' '
857 mkdir -p a/b &&
858 ( echo sixth && echo fifth ) >expect &&
859 ( cd a/b && git log --format=%s .. ) >actual &&
860 test_cmp expect actual
861'
862
863test_expect_success GPG 'setup signed branch' '
864 test_when_finished "git reset --hard && git checkout master" &&
865 git checkout -b signed master &&
866 echo foo >foo &&
867 git add foo &&
868 git commit -S -m signed_commit
869'
870
871test_expect_success GPG 'log --graph --show-signature' '
872 git log --graph --show-signature -n1 signed >actual &&
873 grep "^| gpg: Signature made" actual &&
874 grep "^| gpg: Good signature" actual
875'
876
877test_expect_success GPG 'log --graph --show-signature for merged tag' '
878 test_when_finished "git reset --hard && git checkout master" &&
879 git checkout -b plain master &&
880 echo aaa >bar &&
881 git add bar &&
882 git commit -m bar_commit &&
883 git checkout -b tagged master &&
884 echo bbb >baz &&
885 git add baz &&
886 git commit -m baz_commit &&
887 git tag -s -m signed_tag_msg signed_tag &&
888 git checkout plain &&
889 git merge --no-ff -m msg signed_tag &&
890 git log --graph --show-signature -n1 plain >actual &&
891 grep "^|\\\ merged tag" actual &&
892 grep "^| | gpg: Signature made" actual &&
893 grep "^| | gpg: Good signature" actual
894'
895
896test_expect_success GPG '--no-show-signature overrides --show-signature' '
897 git log -1 --show-signature --no-show-signature signed >actual &&
898 ! grep "^gpg:" actual
899'
900
901test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
902 test_config log.showsignature true &&
903 git log -1 signed >actual &&
904 grep "gpg: Signature made" actual &&
905 grep "gpg: Good signature" actual
906'
907
908test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
909 test_config log.showsignature true &&
910 git log -1 --no-show-signature signed >actual &&
911 ! grep "^gpg:" actual
912'
913
914test_expect_success GPG '--show-signature overrides log.showsignature=false' '
915 test_config log.showsignature false &&
916 git log -1 --show-signature signed >actual &&
917 grep "gpg: Signature made" actual &&
918 grep "gpg: Good signature" actual
919'
920
921test_expect_success 'log --graph --no-walk is forbidden' '
922 test_must_fail git log --graph --no-walk
923'
924
925test_expect_success 'log diagnoses bogus HEAD' '
926 git init empty &&
927 test_must_fail git -C empty log 2>stderr &&
928 test_i18ngrep does.not.have.any.commits stderr &&
929 echo 1234abcd >empty/.git/refs/heads/master &&
930 test_must_fail git -C empty log 2>stderr &&
931 test_i18ngrep broken stderr &&
932 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
933 test_must_fail git -C empty log 2>stderr &&
934 test_i18ngrep broken stderr &&
935 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
936 test_i18ngrep broken stderr
937'
938
939test_expect_success 'set up --source tests' '
940 git checkout --orphan source-a &&
941 test_commit one &&
942 test_commit two &&
943 git checkout -b source-b HEAD^ &&
944 test_commit three
945'
946
947test_expect_success 'log --source paints branch names' '
948 cat >expect <<-\EOF &&
949 09e12a9 source-b three
950 8e393e1 source-a two
951 1ac6c77 source-b one
952 EOF
953 git log --oneline --source source-a source-b >actual &&
954 test_cmp expect actual
955'
956
957test_expect_success 'log --source paints tag names' '
958 git tag -m tagged source-tag &&
959 cat >expect <<-\EOF &&
960 09e12a9 source-tag three
961 8e393e1 source-a two
962 1ac6c77 source-tag one
963 EOF
964 git log --oneline --source source-tag source-a >actual &&
965 test_cmp expect actual
966'
967
968test_done