3 test_description
='git log'
7 test_expect_success setup
'
12 git commit -m initial &&
17 git commit -m second &&
21 git commit -m third &&
26 git commit -m fourth &&
32 git commit -m fifth &&
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
74 test_expect_success
'oneline' '
76 git log --oneline > actual &&
77 test_cmp expect actual
80 test_expect_success
'diff-filter=A' '
82 actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
83 expect=$(echo fifth ; echo fourth ; echo third ; echo initial) &&
84 test "$actual" = "$expect" || {
86 echo "Actual: $actual"
92 test_expect_success
'diff-filter=M' '
94 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
95 expect=$(echo second) &&
96 test "$actual" = "$expect" || {
98 echo "Actual: $actual"
104 test_expect_success
'diff-filter=D' '
106 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
107 expect=$(echo sixth ; echo third) &&
108 test "$actual" = "$expect" || {
110 echo "Actual: $actual"
116 test_expect_success
'diff-filter=R' '
118 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
119 expect=$(echo third) &&
120 test "$actual" = "$expect" || {
122 echo "Actual: $actual"
128 test_expect_success
'diff-filter=C' '
130 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
131 expect=$(echo fourth) &&
132 test "$actual" = "$expect" || {
134 echo "Actual: $actual"
140 test_expect_success
'git log --follow' '
142 actual=$(git log --follow --pretty="format:%s" ichi) &&
143 expect=$(echo third ; echo second ; echo initial) &&
144 test "$actual" = "$expect" || {
146 echo "Actual: $actual"
157 test_expect_success
'git log --no-walk <commits> sorts by commit time' '
158 git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
159 test_cmp expect actual
167 test_expect_success
'git show <commits> leaves list of commits as given' '
168 git show --oneline -s 5d31159 804a787 394ef78 > actual &&
169 test_cmp expect actual
172 test_expect_success
'setup case sensitivity tests' '
176 git commit -a -m Second
179 test_expect_success
'log --grep' '
180 echo second >expect &&
181 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
182 test_cmp expect actual
185 test_expect_success
'log -i --grep' '
186 echo Second >expect &&
187 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
188 test_cmp expect actual
191 test_expect_success
'log --grep -i' '
192 echo Second >expect &&
193 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
194 test_cmp expect actual
207 test_expect_success
'simple log --graph' '
208 git log --graph --pretty=tformat:%s >actual &&
209 test_cmp expect actual
212 test_expect_success
'set up merge history' '
213 git checkout -b side HEAD~4 &&
214 test_commit side-1 1 1 &&
215 test_commit side-2 2 2 &&
216 git checkout master &&
221 * Merge branch
'side'
235 test_expect_success
'log --graph with merge' '
236 git log --graph --date-order --pretty=tformat:%s |
237 sed "s/ *$//" >actual &&
238 test_cmp expect actual
244 | | Author
: A U Thor
<author@example.com
>
246 | | Merge branch
'side'
249 | | Author
: A U Thor
<author@example.com
>
253 |
* commit tags
/side-1
254 | | Author
: A U Thor
<author@example.com
>
259 | | Author
: A U Thor
<author@example.com
>
264 | | Author
: A U Thor
<author@example.com
>
269 | | Author
: A U Thor
<author@example.com
>
274 |
/ Author
: A U Thor
<author@example.com
>
278 * commit tags
/side-1~
1
279 | Author
: A U Thor
<author@example.com
>
283 * commit tags
/side-1~
2
284 | Author
: A U Thor
<author@example.com
>
288 * commit tags
/side-1~
3
289 Author
: A U Thor
<author@example.com
>
294 test_expect_success
'log --graph with full output' '
295 git log --graph --date-order --pretty=short |
296 git name-rev --name-only --stdin |
297 sed "s/Merge:.*/Merge: A B/;s/ *$//" >actual &&
298 test_cmp expect actual
301 test_expect_success
'set up more tangled history' '
302 git checkout -b tangle HEAD~6 &&
303 test_commit tangle-a tangle-a a &&
304 git merge master~3 &&
306 git checkout master &&
308 git checkout -b reach &&
310 git checkout master &&
311 git checkout -b octopus-a &&
312 test_commit octopus-a &&
313 git checkout master &&
314 git checkout -b octopus-b &&
315 test_commit octopus-b &&
316 git checkout master &&
317 test_commit seventh &&
318 git merge octopus-a octopus-b
323 * Merge commit
'reach'
327 *-. \ Merge commit
'octopus-a'; commit
'octopus-b'
337 * Merge branch
'tangle'
339 |
* Merge branch
'side' (early part
) into tangle
341 |
* \ Merge branch
'master' (early part
) into tangle
344 * | | | Merge branch
'side'
363 test_expect_success
'log --graph with merge' '
364 git log --graph --date-order --pretty=tformat:%s |
365 sed "s/ *$//" >actual &&
366 test_cmp expect actual