summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 931233b)
raw | patch | inline | side by side (parent: 931233b)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 8 Nov 2006 00:20:02 +0000 (16:20 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 8 Nov 2006 00:24:37 +0000 (16:24 -0800) |
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: Junio C Hamano <junkio@cox.net>
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: Junio C Hamano <junkio@cox.net>
builtin-pickaxe.c | patch | blob | history |
diff --git a/builtin-pickaxe.c b/builtin-pickaxe.c
index 673185f96de4430a363b961bc9ab8912444808a1..64999f3577294eb2bfe030be386dacd7b3787bbf 100644 (file)
--- a/builtin-pickaxe.c
+++ b/builtin-pickaxe.c
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;