Skip to content

Commit

Permalink
line-range: fix "blame -L X,-N" regression
Browse files Browse the repository at this point in the history
"blame -L X,-N" is documented as blaming "N lines ending at X".  In
practice, the behavior is achieved by swapping the two range endpoints
if the second is less than the first.  25ed341 (Refactor parse_loc;
2013-03-28) broke this interpretation by removing the swapping code from
blame.c and failing to add it to line-range.c along with other code
relocated from blame.c. Thus, such a range is effectively treated as
empty.  Fix this regression.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Eric Sunshine authored and Junio C Hamano committed Jul 18, 2013
1 parent ed73fe5 commit 3bf65f9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions line-range.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
void *cb_data, long lines, long *begin, long *end,
const char *path)
{
*begin = *end = 0;

if (*arg == ':') {
arg = parse_range_funcname(arg, nth_line_cb, cb_data, lines, begin, end, path);
if (!arg || *arg)
Expand All @@ -226,6 +228,11 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
if (*arg)
return -1;

if (*begin && *end && *end < *begin) {
long tmp;
tmp = *end; *end = *begin; *begin = tmp;
}

return 0;
}

Expand Down

0 comments on commit 3bf65f9

Please sign in to comment.