Thread (7 messages) 7 messages, 3 authors, 2018-05-31

Re: [PATCH] log: prevent error if line range ends past end of file

From: Eric Sunshine <hidden>
Date: 2018-05-30 08:59:34

On Tue, May 29, 2018 at 1:30 AM,  [off-list ref] wrote:
quoted hunk ↗ jump to hunk
If the -L option is used to specify a line range in git log, and the end
of the range is past the end of the file, git will fail with a fatal
error. This commit prevents such behaviour - instead we perform the log
for existing lines within the specified range.

This commit also fixes a corner case where -L ,-n:file would be treated
as a log over the whole file. Now we treat this as -L 1,-n:file and
blame the first line of the file instead.

Signed-off-by: Isabella Stephens <redacted>
---
diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
@@ -86,12 +85,7 @@ test_expect_success '-L ,Y (Y == nlines)' '
 test_expect_success '-L ,Y (Y == nlines + 1)' '
        n=$(expr $(wc -l <b.c) + 1) &&
-       test_must_fail git log -L ,$n:b.c
-'
-
-test_expect_success '-L ,Y (Y == nlines + 2)' '
-       n=$(expr $(wc -l <b.c) + 2) &&
-       test_must_fail git log -L ,$n:b.c
+       git log -L ,$n:b.c
 '
Not sure why you removed the 'n+2' test which was added intentionally,
along with the 'n' and 'n+1' tests, to probe the boundary handling for
correctness. By eliminating 'n+2', coverage is reduced and, even
though your change might be correct at this boundary, some future
breaking change might go undetected.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help