summary refs log tree commit diff
path: root/line-log.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-08-02 15:30:41 -0700
committerJunio C Hamano <gitster@pobox.com>2018-08-02 15:30:41 -0700
commit6566a917d8a8d3070b5fdc94fbe5f6d68a4d656b (patch)
tree5a8ac927a48d840786c5cca578221008f2baf9d1 /line-log.c
parentaf8ac73801eebf0f3690c3875751eb9e108ceda8 (diff)
parent7f81c00f3b1bd45c2954b18550b8e351651f72f3 (diff)
Merge branch 'is/parsing-line-range'
Parsing of -L[<N>][,[<M>]] parameters "git blame" and "git log"
take has been tweaked.

* is/parsing-line-range:
  log: prevent error if line range ends past end of file
  blame: prevent error if range ends past end of file
Diffstat (limited to 'line-log.c')
-rw-r--r--line-log.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/line-log.c b/line-log.c
index fa9cfd5bdb..e5af5d0e45 100644
--- a/line-log.c
+++ b/line-log.c
@@ -598,11 +598,11 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args)
 				    lines, anchor, &begin, &end,
 				    full_name))
 			die("malformed -L argument '%s'", range_part);
-		if (lines < end || ((lines || begin) && lines < begin))
+		if ((!lines && (begin || end)) || lines < begin)
 			die("file %s has only %lu lines", name_part, lines);
 		if (begin < 1)
 			begin = 1;
-		if (end < 1)
+		if (end < 1 || lines < end)
 			end = lines;
 		begin--;
 		line_log_data_insert(&ranges, full_name, begin, end);