]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4202-log.sh
Git 2.9-rc2
[thirdparty/git.git] / t / t4202-log.sh
CommitLineData
0faf2da7
AL
1#!/bin/sh
2
3test_description='git log'
4
5. ./test-lib.sh
cf3983d1 6. "$TEST_DIRECTORY/lib-gpg.sh"
0faf2da7
AL
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
d9305089 20 git mv one ichi &&
0faf2da7
AL
21 test_tick &&
22 git commit -m third &&
23
d9305089
AL
24 cp ichi ein &&
25 git add ein &&
0faf2da7
AL
26 test_tick &&
27 git commit -m fourth &&
28
d9305089
AL
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 &&
0faf2da7 36 test_tick &&
d9305089 37 git commit -m sixth
0faf2da7
AL
38
39'
40
bb93afd5
FC
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
37bb5d74
RS
67cat > expect << EOF
68 This is
69 the sixth
70 commit.
71 This is
72 the fifth
73 commit.
74EOF
75
14e1a4e1 76test_expect_success 'format %w(11,1,2)' '
37bb5d74 77
14e1a4e1 78 git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
37bb5d74
RS
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
bb93afd5
FC
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
0faf2da7
AL
102test_expect_success 'diff-filter=A' '
103
5404c116
MM
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 &&
dea007fb
MM
106 printf "fifth\nfourth\nthird\ninitial" > expect &&
107 test_cmp expect actual &&
108 test_cmp expect actual-separate
0faf2da7
AL
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) &&
a167ece0 116 verbose test "$actual" = "$expect"
0faf2da7
AL
117
118'
119
120test_expect_success 'diff-filter=D' '
121
5404c116 122 actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
d9305089 123 expect=$(echo sixth ; echo third) &&
a167ece0 124 verbose test "$actual" = "$expect"
d9305089
AL
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) &&
a167ece0 132 verbose test "$actual" = "$expect"
d9305089
AL
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) &&
a167ece0 140 verbose test "$actual" = "$expect"
d9305089
AL
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) &&
a167ece0 148 verbose test "$actual" = "$expect"
076c9837
DT
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'
0faf2da7 157
076c9837
DT
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"
0faf2da7
AL
173'
174
d5cee0f7
MG
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
ca92e59e
MZ
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
d5cee0f7
MG
190cat > expect << EOF
1915d31159 fourth
192804a787 sixth
193394ef78 fifth
194EOF
ca92e59e
MZ
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
d5cee0f7
MG
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
0843acfd
JK
205test_expect_success 'setup case sensitivity tests' '
206 echo case >one &&
207 test_tick &&
a48fcd83 208 git add one &&
0843acfd
JK
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 &&
22dfa8a2
CJ
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 &&
0843acfd
JK
230 test_cmp expect actual
231'
0faf2da7 232
7d7b86f7
MM
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
0843acfd
JK
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'
0faf2da7 251
34a4ae55
JH
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
289e1623
TR
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 |
9524cf29 298 sed "s/ *\$//" >actual &&
289e1623
TR
299 test_cmp expect actual
300'
301
656197ad
MK
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
289e1623
TR
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 |
9524cf29 368 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
289e1623
TR
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 &&
7b1d6269
AC
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 &&
a48fcd83 389 git merge octopus-a octopus-b &&
7b1d6269 390 git merge reach
289e1623
TR
391'
392
393cat > expect <<\EOF
57b58db7 394* Merge tag 'reach'
7b1d6269
AC
395|\
396| \
397| \
57b58db7 398*-. \ Merge tags 'octopus-a' and 'octopus-b'
7b1d6269
AC
399|\ \ \
400* | | | seventh
401| | * | octopus-b
402| |/ /
403|/| |
404| * | octopus-a
405|/ /
406| * reach
407|/
289e1623
TR
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
eaf158f8 418| | |_|/
289e1623
TR
419| |/| |
420| * | | side-1
421* | | | Second
422* | | | sixth
eaf158f8 423| |_|/
289e1623
TR
424|/| |
425* | | fifth
426* | | fourth
427|/ /
428* | third
429|/
430* second
431* initial
432EOF
433
95110d75 434test_expect_success 'log --graph with merge' '
289e1623 435 git log --graph --date-order --pretty=tformat:%s |
9524cf29 436 sed "s/ *\$//" >actual &&
289e1623
TR
437 test_cmp expect actual
438'
439
8a3d203b 440test_expect_success 'log.decorate configuration' '
4f62c2bc
JH
441 git log --oneline >expect.none &&
442 git log --oneline --decorate >expect.short &&
443 git log --oneline --decorate=full >expect.full &&
8a3d203b
JH
444
445 echo "[log] decorate" >>.git/config &&
635530a2 446 git log --oneline >actual &&
4f62c2bc 447 test_cmp expect.short actual &&
8a3d203b 448
90e76b70 449 test_config log.decorate true &&
4f62c2bc 450 git log --oneline >actual &&
8a3d203b 451 test_cmp expect.short actual &&
4f62c2bc 452 git log --oneline --decorate=full >actual &&
8a3d203b 453 test_cmp expect.full actual &&
4f62c2bc 454 git log --oneline --decorate=no >actual &&
8a3d203b
JH
455 test_cmp expect.none actual &&
456
90e76b70 457 test_config log.decorate no &&
4f62c2bc 458 git log --oneline >actual &&
8a3d203b 459 test_cmp expect.none actual &&
4f62c2bc 460 git log --oneline --decorate >actual &&
8a3d203b 461 test_cmp expect.short actual &&
4f62c2bc 462 git log --oneline --decorate=full >actual &&
8a3d203b
JH
463 test_cmp expect.full actual &&
464
90e76b70 465 test_config log.decorate 1 &&
b2be2f6a
JK
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
90e76b70 473 test_config log.decorate short &&
4f62c2bc 474 git log --oneline >actual &&
8a3d203b 475 test_cmp expect.short actual &&
4f62c2bc 476 git log --oneline --no-decorate >actual &&
8a3d203b 477 test_cmp expect.none actual &&
4f62c2bc 478 git log --oneline --decorate=full >actual &&
8a3d203b
JH
479 test_cmp expect.full actual &&
480
90e76b70 481 test_config log.decorate full &&
4f62c2bc 482 git log --oneline >actual &&
8a3d203b 483 test_cmp expect.full actual &&
4f62c2bc 484 git log --oneline --no-decorate >actual &&
8a3d203b 485 test_cmp expect.none actual &&
4f62c2bc 486 git log --oneline --decorate >actual &&
8fb26872 487 test_cmp expect.short actual &&
8a3d203b 488
90e76b70 489 test_unconfig log.decorate &&
0c47695a 490 git log --pretty=raw >expect.raw &&
90e76b70 491 test_config log.decorate full &&
0c47695a
JS
492 git log --pretty=raw >actual &&
493 test_cmp expect.raw actual
494
495'
496
497test_expect_success 'reflog is expected format' '
0c47695a
JS
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' '
0c47695a
JS
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
90e76b70 518 test_config log.abbrevCommit true &&
0c47695a
JS
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
8a3d203b
JH
537'
538
65113121
ÆAB
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'
c65233fe 551
46ec510a
CB
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
e2c59667
LP
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| | ---
dc801e71 578| | reach.t | 1 +
e2c59667
LP
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| | | ---
dc801e71 601| | | octopus-b.t | 1 +
e2c59667
LP
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| | ---
dc801e71 617| | octopus-a.t | 1 +
e2c59667
LP
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| ---
dc801e71 633| seventh.t | 1 +
e2c59667
LP
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| | | | ---
dc801e71 667| | | | tangle-a | 1 +
e2c59667
LP
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| | | | ---
dc801e71 689| | | | 2 | 1 +
e2c59667
LP
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| | | | ---
dc801e71 705| | | | 1 | 1 +
e2c59667
LP
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| | | | ---
dc801e71 721| | | | one | 1 +
e2c59667
LP
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| | | ---
dc801e71 737| | | a/two | 1 -
e2c59667
LP
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| | | ---
dc801e71 753| | | a/two | 1 +
e2c59667
LP
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| | ---
dc801e71 769| | ein | 1 +
e2c59667
LP
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| ---
dc801e71
ZJS
785| ichi | 1 +
786| one | 1 -
e2c59667
LP
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| ---
dc801e71 809| one | 2 +-
e2c59667
LP
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 ---
dc801e71 825 one | 1 +
e2c59667
LP
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' '
5404c116 851 git log --no-renames --graph --pretty=short --stat -p >actual &&
e2c59667 852 sanitize_output >actual.sanitized <actual &&
b354f11b 853 test_i18ncmp expect actual.sanitized
e2c59667
LP
854'
855
003c84f6
JH
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
cf3983d1
ZK
863test_expect_success GPG 'log --graph --show-signature' '
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 git log --graph --show-signature -n1 signed >actual &&
870 grep "^| gpg: Signature made" actual &&
871 grep "^| gpg: Good signature" actual
872'
873
874test_expect_success GPG 'log --graph --show-signature for merged tag' '
875 test_when_finished "git reset --hard && git checkout master" &&
876 git checkout -b plain master &&
877 echo aaa >bar &&
878 git add bar &&
879 git commit -m bar_commit &&
880 git checkout -b tagged master &&
881 echo bbb >baz &&
882 git add baz &&
883 git commit -m baz_commit &&
884 git tag -s -m signed_tag_msg signed_tag &&
885 git checkout plain &&
886 git merge --no-ff -m msg signed_tag &&
887 git log --graph --show-signature -n1 plain >actual &&
888 grep "^|\\\ merged tag" actual &&
889 grep "^| | gpg: Signature made" actual &&
890 grep "^| | gpg: Good signature" actual
891'
892
695985f4
DJ
893test_expect_success 'log --graph --no-walk is forbidden' '
894 test_must_fail git log --graph --no-walk
895'
896
ce113604
JK
897test_expect_success 'log diagnoses bogus HEAD' '
898 git init empty &&
899 test_must_fail git -C empty log 2>stderr &&
900 test_i18ngrep does.not.have.any.commits stderr &&
901 echo 1234abcd >empty/.git/refs/heads/master &&
902 test_must_fail git -C empty log 2>stderr &&
903 test_i18ngrep broken stderr &&
904 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
905 test_must_fail git -C empty log 2>stderr &&
906 test_i18ngrep broken stderr &&
907 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
908 test_i18ngrep broken stderr
909'
910
728350b7
JK
911test_expect_success 'set up --source tests' '
912 git checkout --orphan source-a &&
913 test_commit one &&
914 test_commit two &&
915 git checkout -b source-b HEAD^ &&
916 test_commit three
917'
918
919test_expect_success 'log --source paints branch names' '
920 cat >expect <<-\EOF &&
921 09e12a9 source-b three
922 8e393e1 source-a two
923 1ac6c77 source-b one
924 EOF
925 git log --oneline --source source-a source-b >actual &&
926 test_cmp expect actual
927'
928
929test_expect_success 'log --source paints tag names' '
930 git tag -m tagged source-tag &&
931 cat >expect <<-\EOF &&
932 09e12a9 source-tag three
933 8e393e1 source-a two
934 1ac6c77 source-tag one
935 EOF
936 git log --oneline --source source-tag source-a >actual &&
937 test_cmp expect actual
938'
939
65113121 940test_done