line-range: teach -L^/RE/ to search from start of file

The -L/RE/ option of blame/log searches from the end of the previous -L
range, if any. Add new notation -L^/RE/ to override this behavior and
search from start of file.

The new ^/RE/ syntax is valid only as the <start> argument of
-L<start>,<end>. The <end> argument, as usual, is relative to <start>.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Sunshine
2013-08-06 09:59:45 -04:00
committed by Junio C Hamano
parent 0bc2cdd550
commit a6ac5f9864
3 changed files with 30 additions and 2 deletions

View File

@@ -59,8 +59,14 @@ static const char *parse_loc(const char *spec, nth_line_fn_t nth_line,
return term;
}
if (begin < 0)
begin = -begin;
if (begin < 0) {
if (spec[0] != '^')
begin = -begin;
else {
begin = 1;
spec++;
}
}
if (spec[0] != '/')
return spec;