Skip to content

Commit e9682cc

Browse files
committed
Merge branch 'es/blame-L-breakage'
The refactoring made for parsing "-L" option recently to support "git log -L" seems to have broken "git blame -L X,-5" to show 5 lines leading to X. * es/blame-L-breakage: blame-options.txt: explain that -L <start> and <end> are optional blame-options.txt: place each -L option variation on its own line t8001/t8002 (blame): add blame -L :funcname tests t8001/t8002 (blame): add blame -L tests t8001/t8002 (blame): modernize style line-range: fix "blame -L X,-N" regression
2 parents cb29dfd + df83d5c commit e9682cc

File tree

5 files changed

+283
-115
lines changed

5 files changed

+283
-115
lines changed

Documentation/blame-options.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
--show-stats::
1010
Include additional statistics at the end of blame output.
1111

12-
-L <start>,<end>, -L :<regex>::
13-
Annotate only the given line range. <start> and <end> can take
14-
one of these forms:
12+
-L <start>,<end>::
13+
-L :<regex>::
14+
Annotate only the given line range. <start> and <end> are optional.
15+
``-L <start>'' or ``-L <start>,'' spans from <start> to end of file.
16+
``-L ,<end>'' spans from start of file to <end>.
17+
+
18+
<start> and <end> can take one of these forms:
1519

1620
include::line-range-format.txt[]
1721

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)