Skip to content

Commit a8fa8ec

Browse files
sunshinecogitster
authored andcommitted
t8001/t8002: blame: add empty file & partial-line tests
Add boundary case tests, with and without -L, for empty file; file with one partial line; file with one full line. The empty file test without -L is of particular interest. Historically, this case has been supported (empty blame output) and this test protects against regression by a subsequent patch fixing an off-by-one bug which incorrectly accepts -LX where X is one past end-of-file. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 580b4f3 commit a8fa8ec

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

t/annotate-tests.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,78 @@ test_expect_success 'blame -L :nomatch' '
297297
test_must_fail $PROG -L:nomatch hello.c
298298
'
299299

300+
test_expect_success 'setup incremental' '
301+
(
302+
GIT_AUTHOR_NAME=I &&
303+
export GIT_AUTHOR_NAME &&
304+
GIT_AUTHOR_EMAIL=I@test.git &&
305+
export GIT_AUTHOR_EMAIL &&
306+
>incremental &&
307+
git add incremental &&
308+
git commit -m "step 0" &&
309+
printf "partial" >>incremental &&
310+
git commit -a -m "step 0.5" &&
311+
echo >>incremental &&
312+
git commit -a -m "step 1"
313+
)
314+
'
315+
316+
test_expect_success 'blame empty' '
317+
check_count -h HEAD^^ -f incremental
318+
'
319+
320+
test_expect_success 'blame -L 0 empty (undocumented)' '
321+
check_count -h HEAD^^ -f incremental -L0
322+
'
323+
324+
test_expect_failure 'blame -L 1 empty' '
325+
test_must_fail $PROG -L1 incremental HEAD^^
326+
'
327+
328+
test_expect_success 'blame -L 2 empty' '
329+
test_must_fail $PROG -L2 incremental HEAD^^
330+
'
331+
332+
test_expect_success 'blame half' '
333+
check_count -h HEAD^ -f incremental I 1
334+
'
335+
336+
test_expect_success 'blame -L 0 half (undocumented)' '
337+
check_count -h HEAD^ -f incremental -L0 I 1
338+
'
339+
340+
test_expect_success 'blame -L 1 half' '
341+
check_count -h HEAD^ -f incremental -L1 I 1
342+
'
343+
344+
test_expect_failure 'blame -L 2 half' '
345+
test_must_fail $PROG -L2 incremental HEAD^
346+
'
347+
348+
test_expect_success 'blame -L 3 half' '
349+
test_must_fail $PROG -L3 incremental HEAD^
350+
'
351+
352+
test_expect_success 'blame full' '
353+
check_count -f incremental I 1
354+
'
355+
356+
test_expect_success 'blame -L 0 full (undocumented)' '
357+
check_count -f incremental -L0 I 1
358+
'
359+
360+
test_expect_success 'blame -L 1 full' '
361+
check_count -f incremental -L1 I 1
362+
'
363+
364+
test_expect_failure 'blame -L 2 full' '
365+
test_must_fail $PROG -L2 incremental
366+
'
367+
368+
test_expect_success 'blame -L 3 full' '
369+
test_must_fail $PROG -L3 incremental
370+
'
371+
300372
test_expect_success 'blame -L' '
301373
test_must_fail $PROG -L file
302374
'

0 commit comments

Comments
 (0)