summaryrefslogtreecommitdiff
path: root/line-range.c
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2013-08-06 09:59:47 -0400
committerJunio C Hamano <gitster@pobox.com>2013-08-06 14:48:02 -0700
commit215e76c7ff8be46b8206c45aed3b6ec29069d4fc (patch)
treef832aea7509f86446d5a123e6c4748d937a2e21f /line-range.c
parent1ce761a524e34f2d629759cb57c67d13acbe4a7a (diff)
downloadgit-215e76c7ff8be46b8206c45aed3b6ec29069d4fc.tar.gz
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. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'line-range.c')
-rw-r--r--line-range.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/line-range.c b/line-range.c
index 4bae4bff21..ede0c6c98f 100644
--- a/line-range.c
+++ b/line-range.c
@@ -173,6 +173,11 @@ static const char *parse_range_funcname(const char *arg, nth_line_fn_t nth_line_
int reg_error;
regex_t regexp;
+ if (*arg == '^') {
+ anchor = 1;
+ arg++;
+ }
+
assert(*arg == ':');
term = arg+1;
while (*term && *term != ':') {
@@ -245,7 +250,7 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
if (anchor > lines)
anchor = lines + 1;
- if (*arg == ':') {
+ if (*arg == ':' || (*arg == '^' && *(arg + 1) == ':')) {
arg = parse_range_funcname(arg, nth_line_cb, cb_data, lines, anchor, begin, end, path);
if (!arg || *arg)
return -1;
@@ -270,7 +275,7 @@ int parse_range_arg(const char *arg, nth_line_fn_t nth_line_cb,
const char *skip_range_arg(const char *arg)
{
- if (*arg == ':')
+ if (*arg == ':' || (*arg == '^' && *(arg + 1) == ':'))
return parse_range_funcname(arg, NULL, NULL, 0, 0, NULL, NULL, NULL);
arg = parse_loc(arg, NULL, NULL, 0, -1, NULL);