line-range: reject -L line numbers less than 1
Since inception, git-blame -L has been documented as accepting 1-based line numbers. When handed a line number less than 1, -L's behavior is undocumented and undefined; it's also nonsensical and should be diagnosed as an error. Do so. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
9527604f7d
commit
5ce922a014
@@ -54,8 +54,11 @@ static const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
|
||||
}
|
||||
num = strtol(spec, &term, 10);
|
||||
if (term != spec) {
|
||||
if (ret)
|
||||
if (ret) {
|
||||
if (num <= 0)
|
||||
die("-L invalid line number: %ld", num);
|
||||
*ret = num;
|
||||
}
|
||||
return term;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user