summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 153559a)
raw | patch | inline | side by side (parent: 153559a)
author | Jay Soffian <jaysoffian@gmail.com> | |
Tue, 9 Feb 2010 03:48:13 +0000 (22:48 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 9 Feb 2010 05:52:44 +0000 (21:52 -0800) |
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 <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-blame.c | patch | blob | history | |
t/t8003-blame.sh | patch | blob | history |
diff --git a/builtin-blame.c b/builtin-blame.c
index 98e818ce6a63b352182b428b49464596d37a0617..4094f3c06111e365c6ab6063746e5928bd2ee8a1 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
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));
diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
index ad834f200ac0d6ecf532374311d896557a9b941d..4a8db74f7e09a143e73d647479ef62af91547865 100755 (executable)
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
git --no-pager blame $COMMIT -- uno >/dev/null
'
+test_expect_success 'blame -L with invalid start' '
+ test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines"
+'
+
+test_expect_success 'blame -L with invalid end' '
+ git blame -L1,5 tres 2>&1 | grep "has only 2 lines"
+'
+
test_done