Skip to content

Commit

Permalink
blame: reject empty ranges -LX,+0 and -LX,-0
Browse files Browse the repository at this point in the history
Empty ranges -LX,+0 and -LX,-0 are nonsensical in the context of blame
yet they are accepted (in fact, both are interpreted as -LX,+2).  Report
them as invalid.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Eric Sunshine authored and Junio C Hamano committed Aug 5, 2013
1 parent dedb912 commit abba353
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions line-range.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ static const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
if (term != spec + 1) {
if (!ret)
return term;
if (num == 0)
die("-L invalid empty range");
if (spec[0] == '-')
num = 0 - num;
if (0 < num)
Expand Down
4 changes: 2 additions & 2 deletions t/annotate-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test_expect_success 'blame -L Y,X (undocumented)' '
check_count -L6,3 B 1 B1 1 B2 1 D 1
'

test_expect_failure 'blame -L X,+0' '
test_expect_success 'blame -L X,+0' '
test_must_fail $PROG -L1,+0 file
'

Expand All @@ -197,7 +197,7 @@ test_expect_success 'blame -L X,+N' '
check_count -L3,+4 B 1 B1 1 B2 1 D 1
'

test_expect_failure 'blame -L X,-0' '
test_expect_success 'blame -L X,-0' '
test_must_fail $PROG -L1,-0 file
'

Expand Down

0 comments on commit abba353

Please sign in to comment.