提交 7bd9641d 编写于 作者: J Junio C Hamano

git-pickaxe: allow "-L <something>,+N"

With this,

	git pickaxe -L '/--progress/,+20' v1.4.0 -- pack-objects.c

gives you 20 lines starting from the first occurrence of
'--progress' in pack-objects, digging from v1.4.0 version.

You can also say

	git pickaxe -L '/--progress/,-5' v1.4.0 -- pack-objects.c
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 931233bc
......@@ -1545,6 +1545,25 @@ static const char *parse_loc(const char *spec,
regex_t regexp;
regmatch_t match[1];
/* Allow "-L <something>,+20" to mean starting at <something>
* for 20 lines, or "-L <something>,-5" for 5 lines ending at
* <something>.
*/
if (1 < begin && (spec[0] == '+' || spec[0] == '-')) {
num = strtol(spec + 1, &term, 10);
if (term != spec + 1) {
if (spec[0] == '-')
num = 0 - num;
if (0 < num)
*ret = begin + num - 2;
else if (!num)
*ret = begin;
else
*ret = begin + num;
return term;
}
return spec;
}
num = strtol(spec, &term, 10);
if (term != spec) {
*ret = num;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册