]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4202-log.sh
color.c: trim leading spaces in color_parse_mem()
[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
8465541e
JH
258test_expect_success 'log with grep.patternType configuration' '
259 >expect &&
260 git -c grep.patterntype=fixed \
261 log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
262 test_cmp expect actual
263'
264
265test_expect_success 'log with grep.patternType configuration and command line' '
266 echo second >expect &&
267 git -c grep.patterntype=fixed \
268 log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
269 test_cmp expect actual
270'
271
289e1623
TR
272cat > expect <<EOF
273* Second
274* sixth
275* fifth
276* fourth
277* third
278* second
279* initial
280EOF
281
282test_expect_success 'simple log --graph' '
283 git log --graph --pretty=tformat:%s >actual &&
284 test_cmp expect actual
285'
286
287test_expect_success 'set up merge history' '
288 git checkout -b side HEAD~4 &&
289 test_commit side-1 1 1 &&
290 test_commit side-2 2 2 &&
291 git checkout master &&
292 git merge side
293'
294
295cat > expect <<\EOF
296* Merge branch 'side'
297|\
298| * side-2
299| * side-1
300* | Second
301* | sixth
302* | fifth
303* | fourth
304|/
305* third
306* second
307* initial
308EOF
309
310test_expect_success 'log --graph with merge' '
311 git log --graph --date-order --pretty=tformat:%s |
9524cf29 312 sed "s/ *\$//" >actual &&
289e1623
TR
313 test_cmp expect actual
314'
315
656197ad
MK
316test_expect_success 'log --raw --graph -m with merge' '
317 git log --raw --graph --oneline -m master | head -n 500 >actual &&
318 grep "initial" actual
319'
320
321test_expect_success 'diff-tree --graph' '
322 git diff-tree --graph master^ | head -n 500 >actual &&
323 grep "one" actual
324'
325
289e1623
TR
326cat > expect <<\EOF
327* commit master
328|\ Merge: A B
329| | Author: A U Thor <author@example.com>
330| |
331| | Merge branch 'side'
332| |
333| * commit side
334| | Author: A U Thor <author@example.com>
335| |
336| | side-2
337| |
338| * commit tags/side-1
339| | Author: A U Thor <author@example.com>
340| |
341| | side-1
342| |
343* | commit master~1
344| | Author: A U Thor <author@example.com>
345| |
346| | Second
347| |
348* | commit master~2
349| | Author: A U Thor <author@example.com>
350| |
351| | sixth
352| |
353* | commit master~3
354| | Author: A U Thor <author@example.com>
355| |
356| | fifth
357| |
358* | commit master~4
359|/ Author: A U Thor <author@example.com>
360|
361| fourth
362|
363* commit tags/side-1~1
364| Author: A U Thor <author@example.com>
365|
366| third
367|
368* commit tags/side-1~2
369| Author: A U Thor <author@example.com>
370|
371| second
372|
373* commit tags/side-1~3
374 Author: A U Thor <author@example.com>
375
376 initial
377EOF
378
379test_expect_success 'log --graph with full output' '
380 git log --graph --date-order --pretty=short |
381 git name-rev --name-only --stdin |
9524cf29 382 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
289e1623
TR
383 test_cmp expect actual
384'
385
386test_expect_success 'set up more tangled history' '
387 git checkout -b tangle HEAD~6 &&
388 test_commit tangle-a tangle-a a &&
389 git merge master~3 &&
390 git merge side~1 &&
391 git checkout master &&
7b1d6269
AC
392 git merge tangle &&
393 git checkout -b reach &&
394 test_commit reach &&
395 git checkout master &&
396 git checkout -b octopus-a &&
397 test_commit octopus-a &&
398 git checkout master &&
399 git checkout -b octopus-b &&
400 test_commit octopus-b &&
401 git checkout master &&
402 test_commit seventh &&
a48fcd83 403 git merge octopus-a octopus-b &&
7b1d6269 404 git merge reach
289e1623
TR
405'
406
407cat > expect <<\EOF
57b58db7 408* Merge tag 'reach'
7b1d6269
AC
409|\
410| \
411| \
57b58db7 412*-. \ Merge tags 'octopus-a' and 'octopus-b'
7b1d6269
AC
413|\ \ \
414* | | | seventh
415| | * | octopus-b
416| |/ /
417|/| |
418| * | octopus-a
419|/ /
420| * reach
421|/
289e1623
TR
422* Merge branch 'tangle'
423|\
424| * Merge branch 'side' (early part) into tangle
425| |\
426| * \ Merge branch 'master' (early part) into tangle
427| |\ \
428| * | | tangle-a
429* | | | Merge branch 'side'
430|\ \ \ \
431| * | | | side-2
eaf158f8 432| | |_|/
289e1623
TR
433| |/| |
434| * | | side-1
435* | | | Second
436* | | | sixth
eaf158f8 437| |_|/
289e1623
TR
438|/| |
439* | | fifth
440* | | fourth
441|/ /
442* | third
443|/
444* second
445* initial
446EOF
447
95110d75 448test_expect_success 'log --graph with merge' '
289e1623 449 git log --graph --date-order --pretty=tformat:%s |
9524cf29 450 sed "s/ *\$//" >actual &&
289e1623
TR
451 test_cmp expect actual
452'
453
8a3d203b 454test_expect_success 'log.decorate configuration' '
4f62c2bc
JH
455 git log --oneline >expect.none &&
456 git log --oneline --decorate >expect.short &&
457 git log --oneline --decorate=full >expect.full &&
8a3d203b
JH
458
459 echo "[log] decorate" >>.git/config &&
635530a2 460 git log --oneline >actual &&
4f62c2bc 461 test_cmp expect.short actual &&
8a3d203b 462
90e76b70 463 test_config log.decorate true &&
4f62c2bc 464 git log --oneline >actual &&
8a3d203b 465 test_cmp expect.short actual &&
4f62c2bc 466 git log --oneline --decorate=full >actual &&
8a3d203b 467 test_cmp expect.full actual &&
4f62c2bc 468 git log --oneline --decorate=no >actual &&
8a3d203b
JH
469 test_cmp expect.none actual &&
470
90e76b70 471 test_config log.decorate no &&
4f62c2bc 472 git log --oneline >actual &&
8a3d203b 473 test_cmp expect.none actual &&
4f62c2bc 474 git log --oneline --decorate >actual &&
8a3d203b 475 test_cmp expect.short actual &&
4f62c2bc 476 git log --oneline --decorate=full >actual &&
8a3d203b
JH
477 test_cmp expect.full actual &&
478
90e76b70 479 test_config log.decorate 1 &&
b2be2f6a
JK
480 git log --oneline >actual &&
481 test_cmp expect.short actual &&
482 git log --oneline --decorate=full >actual &&
483 test_cmp expect.full actual &&
484 git log --oneline --decorate=no >actual &&
485 test_cmp expect.none actual &&
486
90e76b70 487 test_config log.decorate short &&
4f62c2bc 488 git log --oneline >actual &&
8a3d203b 489 test_cmp expect.short actual &&
4f62c2bc 490 git log --oneline --no-decorate >actual &&
8a3d203b 491 test_cmp expect.none actual &&
4f62c2bc 492 git log --oneline --decorate=full >actual &&
8a3d203b
JH
493 test_cmp expect.full actual &&
494
90e76b70 495 test_config log.decorate full &&
4f62c2bc 496 git log --oneline >actual &&
8a3d203b 497 test_cmp expect.full actual &&
4f62c2bc 498 git log --oneline --no-decorate >actual &&
8a3d203b 499 test_cmp expect.none actual &&
4f62c2bc 500 git log --oneline --decorate >actual &&
8fb26872 501 test_cmp expect.short actual &&
8a3d203b 502
90e76b70 503 test_unconfig log.decorate &&
0c47695a 504 git log --pretty=raw >expect.raw &&
90e76b70 505 test_config log.decorate full &&
0c47695a
JS
506 git log --pretty=raw >actual &&
507 test_cmp expect.raw actual
508
509'
510
511test_expect_success 'reflog is expected format' '
0c47695a
JS
512 git log -g --abbrev-commit --pretty=oneline >expect &&
513 git reflog >actual &&
514 test_cmp expect actual
515'
516
517test_expect_success 'whatchanged is expected format' '
518 git log --no-merges --raw >expect &&
519 git whatchanged >actual &&
520 test_cmp expect actual
521'
522
523test_expect_success 'log.abbrevCommit configuration' '
0c47695a
JS
524 git log --abbrev-commit >expect.log.abbrev &&
525 git log --no-abbrev-commit >expect.log.full &&
526 git log --pretty=raw >expect.log.raw &&
527 git reflog --abbrev-commit >expect.reflog.abbrev &&
528 git reflog --no-abbrev-commit >expect.reflog.full &&
529 git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
530 git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
531
90e76b70 532 test_config log.abbrevCommit true &&
0c47695a
JS
533
534 git log >actual &&
535 test_cmp expect.log.abbrev actual &&
536 git log --no-abbrev-commit >actual &&
537 test_cmp expect.log.full actual &&
538
539 git log --pretty=raw >actual &&
540 test_cmp expect.log.raw actual &&
541
542 git reflog >actual &&
543 test_cmp expect.reflog.abbrev actual &&
544 git reflog --no-abbrev-commit >actual &&
545 test_cmp expect.reflog.full actual &&
546
547 git whatchanged >actual &&
548 test_cmp expect.whatchanged.abbrev actual &&
549 git whatchanged --no-abbrev-commit >actual &&
550 test_cmp expect.whatchanged.full actual
8a3d203b
JH
551'
552
65113121
ÆAB
553test_expect_success 'show added path under "--follow -M"' '
554 # This tests for a regression introduced in v1.7.2-rc0~103^2~2
555 test_create_repo regression &&
556 (
557 cd regression &&
558 test_commit needs-another-commit &&
559 test_commit foo.bar &&
560 git log -M --follow -p foo.bar.t &&
561 git log -M --follow --stat foo.bar.t &&
562 git log -M --follow --name-only foo.bar.t
563 )
564'
c65233fe 565
46ec510a
CB
566test_expect_success 'git log -c --follow' '
567 test_create_repo follow-c &&
568 (
569 cd follow-c &&
570 test_commit initial file original &&
571 git rm file &&
572 test_commit rename file2 original &&
573 git reset --hard initial &&
574 test_commit modify file foo &&
575 git merge -m merge rename &&
576 git log -c --follow file2
577 )
578'
579
e2c59667
LP
580cat >expect <<\EOF
581* commit COMMIT_OBJECT_NAME
582|\ Merge: MERGE_PARENTS
583| | Author: A U Thor <author@example.com>
584| |
585| | Merge HEADS DESCRIPTION
586| |
587| * commit COMMIT_OBJECT_NAME
588| | Author: A U Thor <author@example.com>
589| |
590| | reach
591| | ---
dc801e71 592| | reach.t | 1 +
e2c59667
LP
593| | 1 file changed, 1 insertion(+)
594| |
595| | diff --git a/reach.t b/reach.t
596| | new file mode 100644
597| | index 0000000..10c9591
598| | --- /dev/null
599| | +++ b/reach.t
600| | @@ -0,0 +1 @@
601| | +reach
602| |
603| \
604*-. \ commit COMMIT_OBJECT_NAME
605|\ \ \ Merge: MERGE_PARENTS
606| | | | Author: A U Thor <author@example.com>
607| | | |
608| | | | Merge HEADS DESCRIPTION
609| | | |
610| | * | commit COMMIT_OBJECT_NAME
611| | |/ Author: A U Thor <author@example.com>
612| | |
613| | | octopus-b
614| | | ---
dc801e71 615| | | octopus-b.t | 1 +
e2c59667
LP
616| | | 1 file changed, 1 insertion(+)
617| | |
618| | | diff --git a/octopus-b.t b/octopus-b.t
619| | | new file mode 100644
620| | | index 0000000..d5fcad0
621| | | --- /dev/null
622| | | +++ b/octopus-b.t
623| | | @@ -0,0 +1 @@
624| | | +octopus-b
625| | |
626| * | commit COMMIT_OBJECT_NAME
627| |/ Author: A U Thor <author@example.com>
628| |
629| | octopus-a
630| | ---
dc801e71 631| | octopus-a.t | 1 +
e2c59667
LP
632| | 1 file changed, 1 insertion(+)
633| |
634| | diff --git a/octopus-a.t b/octopus-a.t
635| | new file mode 100644
636| | index 0000000..11ee015
637| | --- /dev/null
638| | +++ b/octopus-a.t
639| | @@ -0,0 +1 @@
640| | +octopus-a
641| |
642* | commit COMMIT_OBJECT_NAME
643|/ Author: A U Thor <author@example.com>
644|
645| seventh
646| ---
dc801e71 647| seventh.t | 1 +
e2c59667
LP
648| 1 file changed, 1 insertion(+)
649|
650| diff --git a/seventh.t b/seventh.t
651| new file mode 100644
652| index 0000000..9744ffc
653| --- /dev/null
654| +++ b/seventh.t
655| @@ -0,0 +1 @@
656| +seventh
657|
658* commit COMMIT_OBJECT_NAME
659|\ Merge: MERGE_PARENTS
660| | Author: A U Thor <author@example.com>
661| |
662| | Merge branch 'tangle'
663| |
664| * commit COMMIT_OBJECT_NAME
665| |\ Merge: MERGE_PARENTS
666| | | Author: A U Thor <author@example.com>
667| | |
668| | | Merge branch 'side' (early part) into tangle
669| | |
670| * | commit COMMIT_OBJECT_NAME
671| |\ \ Merge: MERGE_PARENTS
672| | | | Author: A U Thor <author@example.com>
673| | | |
674| | | | Merge branch 'master' (early part) into tangle
675| | | |
676| * | | commit COMMIT_OBJECT_NAME
677| | | | Author: A U Thor <author@example.com>
678| | | |
679| | | | tangle-a
680| | | | ---
dc801e71 681| | | | tangle-a | 1 +
e2c59667
LP
682| | | | 1 file changed, 1 insertion(+)
683| | | |
684| | | | diff --git a/tangle-a b/tangle-a
685| | | | new file mode 100644
686| | | | index 0000000..7898192
687| | | | --- /dev/null
688| | | | +++ b/tangle-a
689| | | | @@ -0,0 +1 @@
690| | | | +a
691| | | |
692* | | | commit COMMIT_OBJECT_NAME
693|\ \ \ \ Merge: MERGE_PARENTS
694| | | | | Author: A U Thor <author@example.com>
695| | | | |
696| | | | | Merge branch 'side'
697| | | | |
698| * | | | commit COMMIT_OBJECT_NAME
699| | |_|/ Author: A U Thor <author@example.com>
700| |/| |
701| | | | side-2
702| | | | ---
dc801e71 703| | | | 2 | 1 +
e2c59667
LP
704| | | | 1 file changed, 1 insertion(+)
705| | | |
706| | | | diff --git a/2 b/2
707| | | | new file mode 100644
708| | | | index 0000000..0cfbf08
709| | | | --- /dev/null
710| | | | +++ b/2
711| | | | @@ -0,0 +1 @@
712| | | | +2
713| | | |
714| * | | commit COMMIT_OBJECT_NAME
715| | | | Author: A U Thor <author@example.com>
716| | | |
717| | | | side-1
718| | | | ---
dc801e71 719| | | | 1 | 1 +
e2c59667
LP
720| | | | 1 file changed, 1 insertion(+)
721| | | |
722| | | | diff --git a/1 b/1
723| | | | new file mode 100644
724| | | | index 0000000..d00491f
725| | | | --- /dev/null
726| | | | +++ b/1
727| | | | @@ -0,0 +1 @@
728| | | | +1
729| | | |
730* | | | commit COMMIT_OBJECT_NAME
731| | | | Author: A U Thor <author@example.com>
732| | | |
733| | | | Second
734| | | | ---
dc801e71 735| | | | one | 1 +
e2c59667
LP
736| | | | 1 file changed, 1 insertion(+)
737| | | |
738| | | | diff --git a/one b/one
739| | | | new file mode 100644
740| | | | index 0000000..9a33383
741| | | | --- /dev/null
742| | | | +++ b/one
743| | | | @@ -0,0 +1 @@
744| | | | +case
745| | | |
746* | | | commit COMMIT_OBJECT_NAME
747| |_|/ Author: A U Thor <author@example.com>
748|/| |
749| | | sixth
750| | | ---
dc801e71 751| | | a/two | 1 -
e2c59667
LP
752| | | 1 file changed, 1 deletion(-)
753| | |
754| | | diff --git a/a/two b/a/two
755| | | deleted file mode 100644
756| | | index 9245af5..0000000
757| | | --- a/a/two
758| | | +++ /dev/null
759| | | @@ -1 +0,0 @@
760| | | -ni
761| | |
762* | | commit COMMIT_OBJECT_NAME
763| | | Author: A U Thor <author@example.com>
764| | |
765| | | fifth
766| | | ---
dc801e71 767| | | a/two | 1 +
e2c59667
LP
768| | | 1 file changed, 1 insertion(+)
769| | |
770| | | diff --git a/a/two b/a/two
771| | | new file mode 100644
772| | | index 0000000..9245af5
773| | | --- /dev/null
774| | | +++ b/a/two
775| | | @@ -0,0 +1 @@
776| | | +ni
777| | |
778* | | commit COMMIT_OBJECT_NAME
779|/ / Author: A U Thor <author@example.com>
780| |
781| | fourth
782| | ---
dc801e71 783| | ein | 1 +
e2c59667
LP
784| | 1 file changed, 1 insertion(+)
785| |
786| | diff --git a/ein b/ein
787| | new file mode 100644
788| | index 0000000..9d7e69f
789| | --- /dev/null
790| | +++ b/ein
791| | @@ -0,0 +1 @@
792| | +ichi
793| |
794* | commit COMMIT_OBJECT_NAME
795|/ Author: A U Thor <author@example.com>
796|
797| third
798| ---
dc801e71
ZJS
799| ichi | 1 +
800| one | 1 -
e2c59667
LP
801| 2 files changed, 1 insertion(+), 1 deletion(-)
802|
803| diff --git a/ichi b/ichi
804| new file mode 100644
805| index 0000000..9d7e69f
806| --- /dev/null
807| +++ b/ichi
808| @@ -0,0 +1 @@
809| +ichi
810| diff --git a/one b/one
811| deleted file mode 100644
812| index 9d7e69f..0000000
813| --- a/one
814| +++ /dev/null
815| @@ -1 +0,0 @@
816| -ichi
817|
818* commit COMMIT_OBJECT_NAME
819| Author: A U Thor <author@example.com>
820|
821| second
822| ---
dc801e71 823| one | 2 +-
e2c59667
LP
824| 1 file changed, 1 insertion(+), 1 deletion(-)
825|
826| diff --git a/one b/one
827| index 5626abf..9d7e69f 100644
828| --- a/one
829| +++ b/one
830| @@ -1 +1 @@
831| -one
832| +ichi
833|
834* commit COMMIT_OBJECT_NAME
835 Author: A U Thor <author@example.com>
836
837 initial
838 ---
dc801e71 839 one | 1 +
e2c59667
LP
840 1 file changed, 1 insertion(+)
841
842 diff --git a/one b/one
843 new file mode 100644
844 index 0000000..5626abf
845 --- /dev/null
846 +++ b/one
847 @@ -0,0 +1 @@
848 +one
849EOF
850
851sanitize_output () {
852 sed -e 's/ *$//' \
853 -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
854 -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
855 -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
856 -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
857 -e 's/, 0 deletions(-)//' \
858 -e 's/, 0 insertions(+)//' \
859 -e 's/ 1 files changed, / 1 file changed, /' \
860 -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
861 -e 's/, 1 insertions(+)/, 1 insertion(+)/'
862}
863
864test_expect_success 'log --graph with diff and stats' '
5404c116 865 git log --no-renames --graph --pretty=short --stat -p >actual &&
e2c59667 866 sanitize_output >actual.sanitized <actual &&
b354f11b 867 test_i18ncmp expect actual.sanitized
e2c59667
LP
868'
869
003c84f6
JH
870test_expect_success 'dotdot is a parent directory' '
871 mkdir -p a/b &&
872 ( echo sixth && echo fifth ) >expect &&
873 ( cd a/b && git log --format=%s .. ) >actual &&
874 test_cmp expect actual
875'
876
aefc81ad 877test_expect_success GPG 'setup signed branch' '
cf3983d1
ZK
878 test_when_finished "git reset --hard && git checkout master" &&
879 git checkout -b signed master &&
880 echo foo >foo &&
881 git add foo &&
aefc81ad
MJ
882 git commit -S -m signed_commit
883'
884
885test_expect_success GPG 'log --graph --show-signature' '
cf3983d1
ZK
886 git log --graph --show-signature -n1 signed >actual &&
887 grep "^| gpg: Signature made" actual &&
888 grep "^| gpg: Good signature" actual
889'
890
891test_expect_success GPG 'log --graph --show-signature for merged tag' '
892 test_when_finished "git reset --hard && git checkout master" &&
893 git checkout -b plain master &&
894 echo aaa >bar &&
895 git add bar &&
896 git commit -m bar_commit &&
897 git checkout -b tagged master &&
898 echo bbb >baz &&
899 git add baz &&
900 git commit -m baz_commit &&
901 git tag -s -m signed_tag_msg signed_tag &&
902 git checkout plain &&
903 git merge --no-ff -m msg signed_tag &&
904 git log --graph --show-signature -n1 plain >actual &&
905 grep "^|\\\ merged tag" actual &&
906 grep "^| | gpg: Signature made" actual &&
907 grep "^| | gpg: Good signature" actual
908'
909
aa379999
MJ
910test_expect_success GPG '--no-show-signature overrides --show-signature' '
911 git log -1 --show-signature --no-show-signature signed >actual &&
912 ! grep "^gpg:" actual
913'
914
fce04c3c
MJ
915test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
916 test_config log.showsignature true &&
917 git log -1 signed >actual &&
918 grep "gpg: Signature made" actual &&
919 grep "gpg: Good signature" actual
920'
921
922test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
923 test_config log.showsignature true &&
924 git log -1 --no-show-signature signed >actual &&
925 ! grep "^gpg:" actual
926'
927
928test_expect_success GPG '--show-signature overrides log.showsignature=false' '
929 test_config log.showsignature false &&
930 git log -1 --show-signature signed >actual &&
931 grep "gpg: Signature made" actual &&
932 grep "gpg: Good signature" actual
933'
934
695985f4
DJ
935test_expect_success 'log --graph --no-walk is forbidden' '
936 test_must_fail git log --graph --no-walk
937'
938
ce113604
JK
939test_expect_success 'log diagnoses bogus HEAD' '
940 git init empty &&
941 test_must_fail git -C empty log 2>stderr &&
942 test_i18ngrep does.not.have.any.commits stderr &&
943 echo 1234abcd >empty/.git/refs/heads/master &&
944 test_must_fail git -C empty log 2>stderr &&
945 test_i18ngrep broken stderr &&
946 echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
947 test_must_fail git -C empty log 2>stderr &&
948 test_i18ngrep broken stderr &&
949 test_must_fail git -C empty log --default totally-bogus 2>stderr &&
950 test_i18ngrep broken stderr
951'
952
728350b7
JK
953test_expect_success 'set up --source tests' '
954 git checkout --orphan source-a &&
955 test_commit one &&
956 test_commit two &&
957 git checkout -b source-b HEAD^ &&
958 test_commit three
959'
960
961test_expect_success 'log --source paints branch names' '
962 cat >expect <<-\EOF &&
963 09e12a9 source-b three
964 8e393e1 source-a two
965 1ac6c77 source-b one
966 EOF
967 git log --oneline --source source-a source-b >actual &&
968 test_cmp expect actual
969'
970
971test_expect_success 'log --source paints tag names' '
972 git tag -m tagged source-tag &&
973 cat >expect <<-\EOF &&
974 09e12a9 source-tag three
975 8e393e1 source-a two
976 1ac6c77 source-tag one
977 EOF
978 git log --oneline --source source-tag source-a >actual &&
979 test_cmp expect actual
980'
981
65113121 982test_done