@@ -185,6 +185,14 @@ test_expect_success 'blame -L Y,X (undocumented)' '
185
185
check_count -L6,3 B 1 B1 1 B2 1 D 1
186
186
'
187
187
188
+ test_expect_success ' blame -L ,+0' '
189
+ test_must_fail $PROG -L,+0 file
190
+ '
191
+
192
+ test_expect_success ' blame -L X,+0' '
193
+ test_must_fail $PROG -L1,+0 file
194
+ '
195
+
188
196
test_expect_success ' blame -L X,+1' '
189
197
check_count -L3,+1 B2 1
190
198
'
@@ -193,6 +201,14 @@ test_expect_success 'blame -L X,+N' '
193
201
check_count -L3,+4 B 1 B1 1 B2 1 D 1
194
202
'
195
203
204
+ test_expect_success ' blame -L ,-0' '
205
+ test_must_fail $PROG -L,-0 file
206
+ '
207
+
208
+ test_expect_success ' blame -L X,-0' '
209
+ test_must_fail $PROG -L1,-0 file
210
+ '
211
+
196
212
test_expect_success ' blame -L X,-1' '
197
213
check_count -L3,-1 B2 1
198
214
'
@@ -225,10 +241,32 @@ test_expect_success 'blame -L /RE/,-N' '
225
241
check_count -L/99/,-3 B 1 B2 1 D 1
226
242
'
227
243
244
+ # 'file' ends with an incomplete line, so 'wc' reports one fewer lines than
245
+ # git-blame sees, hence the last line is actually $(wc...)+1.
246
+ test_expect_success ' blame -L X (X == nlines)' '
247
+ n=$(expr $(wc -l <file) + 1) &&
248
+ check_count -L$n C 1
249
+ '
250
+
251
+ test_expect_success ' blame -L X (X == nlines + 1)' '
252
+ n=$(expr $(wc -l <file) + 2) &&
253
+ test_must_fail $PROG -L$n file
254
+ '
255
+
228
256
test_expect_success ' blame -L X (X > nlines)' '
229
257
test_must_fail $PROG -L12345 file
230
258
'
231
259
260
+ test_expect_success ' blame -L ,Y (Y == nlines)' '
261
+ n=$(expr $(wc -l <file) + 1) &&
262
+ check_count -L,$n A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
263
+ '
264
+
265
+ test_expect_success ' blame -L ,Y (Y == nlines + 1)' '
266
+ n=$(expr $(wc -l <file) + 2) &&
267
+ test_must_fail $PROG -L,$n file
268
+ '
269
+
232
270
test_expect_success ' blame -L ,Y (Y > nlines)' '
233
271
test_must_fail $PROG -L,12345 file
234
272
'
@@ -275,12 +313,102 @@ test_expect_success 'blame -L :nomatch' '
275
313
test_must_fail $PROG -L:nomatch hello.c
276
314
'
277
315
278
- test_expect_success ' blame -L bogus' '
279
- test_must_fail $PROG -L file &&
280
- test_must_fail $PROG -L1,+ file &&
281
- test_must_fail $PROG -L1,- file &&
282
- test_must_fail $PROG -LX file &&
283
- test_must_fail $PROG -L1,X file &&
284
- test_must_fail $PROG -L1,+N file &&
316
+ test_expect_success ' setup incremental' '
317
+ (
318
+ GIT_AUTHOR_NAME=I &&
319
+ export GIT_AUTHOR_NAME &&
320
+
321
+ export GIT_AUTHOR_EMAIL &&
322
+ >incremental &&
323
+ git add incremental &&
324
+ git commit -m "step 0" &&
325
+ printf "partial" >>incremental &&
326
+ git commit -a -m "step 0.5" &&
327
+ echo >>incremental &&
328
+ git commit -a -m "step 1"
329
+ )
330
+ '
331
+
332
+ test_expect_success ' blame empty' '
333
+ check_count -h HEAD^^ -f incremental
334
+ '
335
+
336
+ test_expect_success ' blame -L 0 empty (undocumented)' '
337
+ check_count -h HEAD^^ -f incremental -L0
338
+ '
339
+
340
+ test_expect_success ' blame -L 1 empty' '
341
+ test_must_fail $PROG -L1 incremental HEAD^^
342
+ '
343
+
344
+ test_expect_success ' blame -L 2 empty' '
345
+ test_must_fail $PROG -L2 incremental HEAD^^
346
+ '
347
+
348
+ test_expect_success ' blame half' '
349
+ check_count -h HEAD^ -f incremental I 1
350
+ '
351
+
352
+ test_expect_success ' blame -L 0 half (undocumented)' '
353
+ check_count -h HEAD^ -f incremental -L0 I 1
354
+ '
355
+
356
+ test_expect_success ' blame -L 1 half' '
357
+ check_count -h HEAD^ -f incremental -L1 I 1
358
+ '
359
+
360
+ test_expect_success ' blame -L 2 half' '
361
+ test_must_fail $PROG -L2 incremental HEAD^
362
+ '
363
+
364
+ test_expect_success ' blame -L 3 half' '
365
+ test_must_fail $PROG -L3 incremental HEAD^
366
+ '
367
+
368
+ test_expect_success ' blame full' '
369
+ check_count -f incremental I 1
370
+ '
371
+
372
+ test_expect_success ' blame -L 0 full (undocumented)' '
373
+ check_count -f incremental -L0 I 1
374
+ '
375
+
376
+ test_expect_success ' blame -L 1 full' '
377
+ check_count -f incremental -L1 I 1
378
+ '
379
+
380
+ test_expect_success ' blame -L 2 full' '
381
+ test_must_fail $PROG -L2 incremental
382
+ '
383
+
384
+ test_expect_success ' blame -L 3 full' '
385
+ test_must_fail $PROG -L3 incremental
386
+ '
387
+
388
+ test_expect_success ' blame -L' '
389
+ test_must_fail $PROG -L file
390
+ '
391
+
392
+ test_expect_success ' blame -L X,+' '
393
+ test_must_fail $PROG -L1,+ file
394
+ '
395
+
396
+ test_expect_success ' blame -L X,-' '
397
+ test_must_fail $PROG -L1,- file
398
+ '
399
+
400
+ test_expect_success ' blame -L X (non-numeric X)' '
401
+ test_must_fail $PROG -LX file
402
+ '
403
+
404
+ test_expect_success ' blame -L X,Y (non-numeric Y)' '
405
+ test_must_fail $PROG -L1,Y file
406
+ '
407
+
408
+ test_expect_success ' blame -L X,+N (non-numeric N)' '
409
+ test_must_fail $PROG -L1,+N file
410
+ '
411
+
412
+ test_expect_success ' blame -L X,-N (non-numeric N)' '
285
413
test_must_fail $PROG -L1,-N file
286
414
'
0 commit comments