Skip to content

Commit 3bf65f9

Browse files
sunshinecogitster
authored andcommitted
line-range: fix "blame -L X,-N" regression
"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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ed73fe5 commit 3bf65f9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

line-range.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
211211
void *cb_data, long lines, long *begin, long *end,
212212
const char *path)
213213
{
214+
*begin = *end = 0;
215+
214216
if (*arg == ':') {
215217
arg = parse_range_funcname(arg, nth_line_cb, cb_data, lines, begin, end, path);
216218
if (!arg || *arg)
@@ -226,6 +228,11 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
226228
if (*arg)
227229
return -1;
228230

231+
if (*begin && *end && *end < *begin) {
232+
long tmp;
233+
tmp = *end; *end = *begin; *begin = tmp;
234+
}
235+
229236
return 0;
230237
}
231238

0 commit comments

Comments
 (0)