Skip to content

Commit

Permalink
Merge branch 'es/blame-L-breakage'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Jul 22, 2013
2 parents cb29dfd + df83d5c commit e9682cc
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 115 deletions.
10 changes: 7 additions & 3 deletions Documentation/blame-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
--show-stats::
Include additional statistics at the end of blame output.

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

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

Expand Down
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
Loading

0 comments on commit e9682cc

Please sign in to comment.