From: Jay Soffian <hidden> Date: 2016-06-15 22:48:12
blame would segv if given -L <lineno> with <lineno> past the end of the file.
While we're fixing the bug, add test cases for an invalid <start> when called
as -L <start>,<end> or -L<start>.
Signed-off-by: Jay Soffian <redacted>
---
bottom is start and top is end, which seems backwards to me, but alas, it is
what it is. :-)
builtin-blame.c | 2 +-
t/t8003-blame.sh | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletions(-)
@@ -2433,7 +2433,7 @@ parse_done:if(top<1)top=lno;bottom--;-if(lno<top)+if(lno<top||lno<bottom)die("file %s has only %lu lines",path,lno);ent=xcalloc(1,sizeof(*ent));
@@ -157,4 +157,12 @@ EOFgit--no-pagerblame$COMMIT--uno>/dev/null'+test_expect_success'blame -L with invalid start''+test_must_failgitblame-L5tres2>&1|grep"has only 2 lines"+'++test_expect_success'blame -L with invalid end''+gitblame-L1,5tres2>&1|grep"has only 2 lines"+'+ test_done
From: Johannes Sixt <hidden> Date: 2016-06-15 22:48:12
Jay Soffian schrieb:
+test_expect_success 'blame -L with invalid start' '
+ test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines"
Please write this as
test_must_fail git blame -L5 tres >output 2>&1 &&
grep "has only 2 lines" output
+'
+
+test_expect_success 'blame -L with invalid end' '
+ git blame -L1,5 tres 2>&1 | grep "has only 2 lines"
test_must_fail git blame -L1,5 tres >output 2>&1 &&
grep "has only 2 lines" output
because shells look only at the exit code of the last command in a pipeline.
-- Hannes
From: Jay Soffian <hidden> Date: 2016-06-15 22:48:12
On Tue, Feb 9, 2010 at 2:43 AM, Johannes Sixt [off-list ref] wrote:
Jay Soffian schrieb:
quoted
+test_expect_success 'blame -L with invalid start' '
+ test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines"
Please write this as
test_must_fail git blame -L5 tres >output 2>&1 &&
grep "has only 2 lines" output
quoted
+'
+
+test_expect_success 'blame -L with invalid end' '
+ git blame -L1,5 tres 2>&1 | grep "has only 2 lines"
test_must_fail git blame -L1,5 tres >output 2>&1 &&
grep "has only 2 lines" output
because shells look only at the exit code of the last command in a pipeline.
Thanks, I knew that. I'd left in test_must_fail accidentally because
initially I wasn't bothering to grep the output. I then added the grep
and forgot to remove test_must_fail. Isn't this an adequate test:
test_expect_success 'blame -L with invalid start' '
git blame -L5 tres 2>&1 | grep "has only 2 lines"
As it seems unlikely git would crash and still output the message
correctly in this case.
?
j.
From: Jay Soffian <hidden> Date: 2016-06-15 22:48:12
blame would segv if given -L <lineno> with <lineno> past the end of the file.
While we're fixing the bug, add test cases for an invalid <start> when called
as -L <start>,<end> or -L<start>.
Signed-off-by: Jay Soffian <redacted>
---
Modified the tests per Hannes recommendations.
builtin-blame.c | 2 +-
t/t8003-blame.sh | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletions(-)
@@ -2433,7 +2433,7 @@ parse_done:if(top<1)top=lno;bottom--;-if(lno<top)+if(lno<top||lno<bottom)die("file %s has only %lu lines",path,lno);ent=xcalloc(1,sizeof(*ent));
@@ -157,4 +157,14 @@ EOFgit--no-pagerblame$COMMIT--uno>/dev/null'+test_expect_success'blame -L with invalid start''+test_must_failgitblame-L5tres>output2>&1&&+grep"has only 2 lines"output+'++test_expect_success'blame -L with invalid end''+test_must_failgitblame-L1,5tres>output2>&1&&+grep"has only 2 lines"output+'+ test_done