]> git.ipfire.org Git - thirdparty/git.git/commit - line-range.c
blame: prevent error if range ends past end of file
authorIsabella Stephens <istephens@atlassian.com>
Fri, 15 Jun 2018 06:29:27 +0000 (16:29 +1000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 15 Jun 2018 17:29:13 +0000 (10:29 -0700)
commit96cfa94e68cfbe9942e230ae18b35eaf1ca30f99
treea1e806e0b896c3f60c83cecb987c4e8425b6e6e6
parentfc54c1af3ec09bab8b8ea09768c2da4069b7f53e
blame: prevent error if range ends past end of file

If the -L option is used to specify a line range in git blame, and the
end of the range is past the end of the file, git will fail with a fatal
error. This commit prevents such behavior - instead we display the blame
for existing lines within the specified range. Tests are amended
accordingly.

This commit also fixes two corner cases. Blaming -L n,-(n+1) now blames
the first n lines of a file rather than from n to the end of the file.
Blaming -L ,-n will be treated as -L 1,-n and blame the first line of
the file, rather than blaming the whole file.

Signed-off-by: Isabella Stephens <istephens@atlassian.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c
line-range.c
t/annotate-tests.sh
t/t8003-blame-corner-cases.sh