diff: parse separate options --stat-width n, --stat-name-width n
[git/jnareb-git.git] / t / t4202-log.sh
blobc1abd311dc7b467bcb7a7706a82e46ff90a0a9a4
1 #!/bin/sh
3 test_description='git log'
5 . ./test-lib.sh
7 test_expect_success setup '
9 echo one >one &&
10 git add one &&
11 test_tick &&
12 git commit -m initial &&
14 echo ichi >one &&
15 git add one &&
16 test_tick &&
17 git commit -m second &&
19 git mv one ichi &&
20 test_tick &&
21 git commit -m third &&
23 cp ichi ein &&
24 git add ein &&
25 test_tick &&
26 git commit -m fourth &&
28 mkdir a &&
29 echo ni >a/two &&
30 git add a/two &&
31 test_tick &&
32 git commit -m fifth &&
34 git rm a/two &&
35 test_tick &&
36 git commit -m sixth
40 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
41 test_expect_success 'pretty' '
43 git log --pretty="format:%s" > actual &&
44 test_cmp expect actual
47 printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
48 test_expect_success 'pretty (tformat)' '
50 git log --pretty="tformat:%s" > actual &&
51 test_cmp expect actual
54 test_expect_success 'pretty (shortcut)' '
56 git log --pretty="%s" > actual &&
57 test_cmp expect actual
60 test_expect_success 'format' '
62 git log --format="%s" > actual &&
63 test_cmp expect actual
66 cat > expect << EOF
67 This is
68 the sixth
69 commit.
70 This is
71 the fifth
72 commit.
73 EOF
75 test_expect_success 'format %w(12,1,2)' '
77 git log -2 --format="%w(12,1,2)This is the %s commit." > actual &&
78 test_cmp expect actual
81 test_expect_success 'format %w(,1,2)' '
83 git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
84 test_cmp expect actual
87 cat > expect << EOF
88 804a787 sixth
89 394ef78 fifth
90 5d31159 fourth
91 2fbe8c0 third
92 f7dab8e second
93 3a2fdcb initial
94 EOF
95 test_expect_success 'oneline' '
97 git log --oneline > actual &&
98 test_cmp expect actual
101 test_expect_success 'diff-filter=A' '
103 git log --pretty="format:%s" --diff-filter=A HEAD > actual &&
104 git log --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
105 printf "fifth\nfourth\nthird\ninitial" > expect &&
106 test_cmp expect actual &&
107 test_cmp expect actual-separate
111 test_expect_success 'diff-filter=M' '
113 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
114 expect=$(echo second) &&
115 test "$actual" = "$expect" || {
116 echo Oops
117 echo "Actual: $actual"
118 false
123 test_expect_success 'diff-filter=D' '
125 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
126 expect=$(echo sixth ; echo third) &&
127 test "$actual" = "$expect" || {
128 echo Oops
129 echo "Actual: $actual"
130 false
135 test_expect_success 'diff-filter=R' '
137 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
138 expect=$(echo third) &&
139 test "$actual" = "$expect" || {
140 echo Oops
141 echo "Actual: $actual"
142 false
147 test_expect_success 'diff-filter=C' '
149 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
150 expect=$(echo fourth) &&
151 test "$actual" = "$expect" || {
152 echo Oops
153 echo "Actual: $actual"
154 false
159 test_expect_success 'git log --follow' '
161 actual=$(git log --follow --pretty="format:%s" ichi) &&
162 expect=$(echo third ; echo second ; echo initial) &&
163 test "$actual" = "$expect" || {
164 echo Oops
165 echo "Actual: $actual"
166 false
171 cat > expect << EOF
172 804a787 sixth
173 394ef78 fifth
174 5d31159 fourth
176 test_expect_success 'git log --no-walk <commits> sorts by commit time' '
177 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
178 test_cmp expect actual
181 cat > expect << EOF
182 5d31159 fourth
183 804a787 sixth
184 394ef78 fifth
186 test_expect_success 'git show <commits> leaves list of commits as given' '
187 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
188 test_cmp expect actual
191 test_expect_success 'setup case sensitivity tests' '
192 echo case >one &&
193 test_tick &&
194 git add one
195 git commit -a -m Second
198 test_expect_success 'log --grep' '
199 echo second >expect &&
200 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
201 test_cmp expect actual
204 test_expect_success 'log -i --grep' '
205 echo Second >expect &&
206 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
207 test_cmp expect actual
210 test_expect_success 'log --grep -i' '
211 echo Second >expect &&
212 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
213 test_cmp expect actual
216 cat > expect <<EOF
217 * Second
218 * sixth
219 * fifth
220 * fourth
221 * third
222 * second
223 * initial
226 test_expect_success 'simple log --graph' '
227 git log --graph --pretty=tformat:%s >actual &&
228 test_cmp expect actual
231 test_expect_success 'set up merge history' '
232 git checkout -b side HEAD~4 &&
233 test_commit side-1 1 1 &&
234 test_commit side-2 2 2 &&
235 git checkout master &&
236 git merge side
239 cat > expect <<\EOF
240 * Merge branch 'side'
242 | * side-2
243 | * side-1
244 * | Second
245 * | sixth
246 * | fifth
247 * | fourth
249 * third
250 * second
251 * initial
254 test_expect_success 'log --graph with merge' '
255 git log --graph --date-order --pretty=tformat:%s |
256 sed "s/ *\$//" >actual &&
257 test_cmp expect actual
260 cat > expect <<\EOF
261 * commit master
262 |\ Merge: A B
263 | | Author: A U Thor <author@example.com>
265 | | Merge branch 'side'
267 | * commit side
268 | | Author: A U Thor <author@example.com>
270 | | side-2
272 | * commit tags/side-1
273 | | Author: A U Thor <author@example.com>
275 | | side-1
277 * | commit master~1
278 | | Author: A U Thor <author@example.com>
280 | | Second
282 * | commit master~2
283 | | Author: A U Thor <author@example.com>
285 | | sixth
287 * | commit master~3
288 | | Author: A U Thor <author@example.com>
290 | | fifth
292 * | commit master~4
293 |/ Author: A U Thor <author@example.com>
295 | fourth
297 * commit tags/side-1~1
298 | Author: A U Thor <author@example.com>
300 | third
302 * commit tags/side-1~2
303 | Author: A U Thor <author@example.com>
305 | second
307 * commit tags/side-1~3
308 Author: A U Thor <author@example.com>
310 initial
313 test_expect_success 'log --graph with full output' '
314 git log --graph --date-order --pretty=short |
315 git name-rev --name-only --stdin |
316 sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
317 test_cmp expect actual
320 test_expect_success 'set up more tangled history' '
321 git checkout -b tangle HEAD~6 &&
322 test_commit tangle-a tangle-a a &&
323 git merge master~3 &&
324 git merge side~1 &&
325 git checkout master &&
326 git merge tangle &&
327 git checkout -b reach &&
328 test_commit reach &&
329 git checkout master &&
330 git checkout -b octopus-a &&
331 test_commit octopus-a &&
332 git checkout master &&
333 git checkout -b octopus-b &&
334 test_commit octopus-b &&
335 git checkout master &&
336 test_commit seventh &&
337 git merge octopus-a octopus-b
338 git merge reach
341 cat > expect <<\EOF
342 * Merge commit 'reach'
346 *-. \ Merge commit 'octopus-a'; commit 'octopus-b'
347 |\ \ \
348 * | | | seventh
349 | | * | octopus-b
350 | |/ /
351 |/| |
352 | * | octopus-a
353 |/ /
354 | * reach
356 * Merge branch 'tangle'
358 | * Merge branch 'side' (early part) into tangle
359 | |\
360 | * \ Merge branch 'master' (early part) into tangle
361 | |\ \
362 | * | | tangle-a
363 * | | | Merge branch 'side'
364 |\ \ \ \
365 | * | | | side-2
366 | | |_|/
367 | |/| |
368 | * | | side-1
369 * | | | Second
370 * | | | sixth
371 | |_|/
372 |/| |
373 * | | fifth
374 * | | fourth
375 |/ /
376 * | third
378 * second
379 * initial
382 test_expect_success 'log --graph with merge' '
383 git log --graph --date-order --pretty=tformat:%s |
384 sed "s/ *\$//" >actual &&
385 test_cmp expect actual
388 test_expect_success 'log.decorate configuration' '
389 git config --unset-all log.decorate || :
391 git log --oneline >expect.none &&
392 git log --oneline --decorate >expect.short &&
393 git log --oneline --decorate=full >expect.full &&
395 echo "[log] decorate" >>.git/config &&
396 git log --oneline >actual &&
397 test_cmp expect.short actual &&
399 git config --unset-all log.decorate &&
400 git config log.decorate true &&
401 git log --oneline >actual &&
402 test_cmp expect.short actual &&
403 git log --oneline --decorate=full >actual &&
404 test_cmp expect.full actual &&
405 git log --oneline --decorate=no >actual &&
406 test_cmp expect.none actual &&
408 git config --unset-all log.decorate &&
409 git config log.decorate no &&
410 git log --oneline >actual &&
411 test_cmp expect.none actual &&
412 git log --oneline --decorate >actual &&
413 test_cmp expect.short actual &&
414 git log --oneline --decorate=full >actual &&
415 test_cmp expect.full actual &&
417 git config --unset-all log.decorate &&
418 git config log.decorate short &&
419 git log --oneline >actual &&
420 test_cmp expect.short actual &&
421 git log --oneline --no-decorate >actual &&
422 test_cmp expect.none actual &&
423 git log --oneline --decorate=full >actual &&
424 test_cmp expect.full actual &&
426 git config --unset-all log.decorate &&
427 git config log.decorate full &&
428 git log --oneline >actual &&
429 test_cmp expect.full actual &&
430 git log --oneline --no-decorate >actual &&
431 test_cmp expect.none actual &&
432 git log --oneline --decorate >actual &&
433 test_cmp expect.short actual
437 test_done