Test log --graph
So far there were no tests checking that log --graph actually works. Note that the tests strip trailing whitespace, as the current --graph emits trailing whitespace on lines that do not contain anything but graph lines. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Feb 19, 2009 at 12:13 UTC
289e162318bbf4b0f90dd70371046e1b20d4c0be
1 file changed
+148
t/t4202-log.sh
+148
@@ -134,5 +134,153 @@ test_expect_success 'log --grep -i' '
134
test_cmp expect actual
135
'
136
137
+cat > expect <<EOF
138
+* Second
139
+* sixth
140
+* fifth
141
+* fourth
142
+* third
143
+* second
144
+* initial
145
+EOF
146
+
147
+test_expect_success 'simple log --graph' '
148
+ git log --graph --pretty=tformat:%s >actual &&
149
+ test_cmp expect actual
150
+'
151
+
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 &&
157
+ git merge side
158
+'
159
+
160
+cat > expect <<\EOF
161
+* Merge branch 'side'
162
+|\
163
+| * side-2
164
+| * side-1
165
+* | Second
166
+* | sixth
167
+* | fifth
168
+* | fourth
169
+|/
170
+* third
171
+* second
172
+* initial
173
+EOF
174
+
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
179
+'
180
+
181
+cat > expect <<\EOF
182
+* commit master
183
+|\ Merge: A B
184
+| | Author: A U Thor <author@example.com>
185
+| |
186
+| | Merge branch 'side'
187
+| |
188
+| * commit side
189
+| | Author: A U Thor <author@example.com>
190
+| |
191
+| | side-2
192
+| |
193
+| * commit tags/side-1
194
+| | Author: A U Thor <author@example.com>
195
+| |
196
+| | side-1
197
+| |
198
+* | commit master~1
199
+| | Author: A U Thor <author@example.com>
200
+| |
201
+| | Second
202
+| |
203
+* | commit master~2
204
+| | Author: A U Thor <author@example.com>
205
+| |
206
+| | sixth
207
+| |
208
+* | commit master~3
209
+| | Author: A U Thor <author@example.com>
210
+| |
211
+| | fifth
212
+| |
213
+* | commit master~4
214
+|/ Author: A U Thor <author@example.com>
215
+|
216
+| fourth
217
+|
218
+* commit tags/side-1~1
219
+| Author: A U Thor <author@example.com>
220
+|
221
+| third
222
+|
223
+* commit tags/side-1~2
224
+| Author: A U Thor <author@example.com>
225
+|
226
+| second
227
+|
228
+* commit tags/side-1~3
229
+ Author: A U Thor <author@example.com>
230
+
231
+ initial
232
+EOF
233
+
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
239
+'
240
+
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 &&
245
+ git merge side~1 &&
246
+ git checkout master &&
247
+ git merge tangle
248
+'
249
+
250
+cat > expect <<\EOF
251
+* Merge branch 'tangle'
252
+|\
253
+| * Merge branch 'side' (early part) into tangle
254
+| |\
255
+| * \ Merge branch 'master' (early part) into tangle
256
+| |\ \
257
+| * | | tangle-a
258
+* | | | Merge branch 'side'
259
+|\ \ \ \
260
+| * | | | side-2
261
+| | | |/
262
+| | |/|
263
+| |/| |
264
+| * | | side-1
265
+* | | | Second
266
+* | | | sixth
267
+| | |/
268
+| |/|
269
+|/| |
270
+* | | fifth
271
+* | | fourth
272
+|/ /
273
+* | third
274
+|/
275
+* second
276
+* initial
277
+EOF
278
+
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
283
+'
284
+
285
test_done
286