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 test_expect_success 'diff-filter=A' '
42 actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
43 expect=$(echo fifth ; echo fourth ; echo third ; echo initial) &&
44 test "$actual" = "$expect" || {
46 echo "Actual: $actual"
52 test_expect_success 'diff-filter=M' '
54 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
55 expect=$(echo second) &&
56 test "$actual" = "$expect" || {
58 echo "Actual: $actual"
64 test_expect_success 'diff-filter=D' '
66 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
67 expect=$(echo sixth ; echo third) &&
68 test "$actual" = "$expect" || {
70 echo "Actual: $actual"
76 test_expect_success 'diff-filter=R' '
78 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
79 expect=$(echo third) &&
80 test "$actual" = "$expect" || {
82 echo "Actual: $actual"
88 test_expect_success 'diff-filter=C' '
90 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
91 expect=$(echo fourth) &&
92 test "$actual" = "$expect" || {
94 echo "Actual: $actual"
100 test_expect_success 'git log --follow' '
102 actual=$(git log --follow --pretty="format:%s" ichi) &&
103 expect=$(echo third ; echo second ; echo initial) &&
104 test "$actual" = "$expect" || {
106 echo "Actual: $actual"
112 test_expect_success 'setup case sensitivity tests' '
116 git commit -a -m Second
119 test_expect_success 'log --grep' '
120 echo second >expect &&
121 git log -1 --pretty="tformat:%s" --grep=sec >actual &&
122 test_cmp expect actual
125 test_expect_success 'log -i --grep' '
126 echo Second >expect &&
127 git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
128 test_cmp expect actual
131 test_expect_success 'log --grep -i' '
132 echo Second >expect &&
133 git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
134 test_cmp expect actual
147 test_expect_success 'simple log --graph' '
148 git log --graph --pretty=tformat:%s >actual &&
149 test_cmp expect actual
152 test_expect_success 'set up merge history' '
153 git checkout -b side HEAD~4 &&
154 test_commit side-1 1 1 &&
155 test_commit side-2 2 2 &&
156 git checkout master &&
161 * Merge branch 'side'
175 test_expect_success 'log --graph with merge' '
176 git log --graph --date-order --pretty=tformat:%s |
177 sed "s/ *$//" >actual &&
178 test_cmp expect actual
184 | | Author: A U Thor <author@example.com>
186 | | Merge branch 'side'
189 | | Author: A U Thor <author@example.com>
193 | * commit tags/side-1
194 | | Author: A U Thor <author@example.com>
199 | | Author: A U Thor <author@example.com>
204 | | Author: A U Thor <author@example.com>
209 | | Author: A U Thor <author@example.com>
214 |/ Author: A U Thor <author@example.com>
218 * commit tags/side-1~1
219 | Author: A U Thor <author@example.com>
223 * commit tags/side-1~2
224 | Author: A U Thor <author@example.com>
228 * commit tags/side-1~3
229 Author: A U Thor <author@example.com>
234 test_expect_success 'log --graph with full output' '
235 git log --graph --date-order --pretty=short |
236 git name-rev --name-only --stdin |
237 sed "s/Merge:.*/Merge: A B/;s/ *$//" >actual &&
238 test_cmp expect actual
241 test_expect_success 'set up more tangled history' '
242 git checkout -b tangle HEAD~6 &&
243 test_commit tangle-a tangle-a a &&
244 git merge master~3 &&
246 git checkout master &&
251 * Merge branch 'tangle'
253 | * Merge branch 'side' (early part) into tangle
255 | * \ Merge branch 'master' (early part) into tangle
258 * | | | Merge branch 'side'
279 test_expect_success 'log --graph with merge' '
280 git log --graph --date-order --pretty=tformat:%s |
281 sed "s/ *$//" >actual &&
282 test_cmp expect actual