]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/blame.c
blame: prevent error if range ends past end of file
[thirdparty/git.git] / builtin / blame.c
index 9dcb367b90d99fc9ebbbf878f53cd5b4651d7864..e1359b1927274c07329ae20eb89fa1662742a1df 100644 (file)
@@ -886,13 +886,13 @@ parse_done:
                                    nth_line_cb, &sb, lno, anchor,
                                    &bottom, &top, sb.path))
                        usage(blame_usage);
-               if (lno < top || ((lno || bottom) && lno < bottom))
+               if ((!lno && (top || bottom)) || lno < bottom)
                        die(Q_("file %s has only %lu line",
                               "file %s has only %lu lines",
                               lno), path, lno);
                if (bottom < 1)
                        bottom = 1;
-               if (top < 1)
+               if (top < 1 || lno < top)
                        top = lno;
                bottom--;
                range_set_append_unsafe(&ranges, bottom, top);