aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-08-23 10:17:03 -0700
committerJunio C Hamano <gitster@pobox.com>2010-08-31 14:30:29 -0700
commitf506b8e8b5fb231e63b69668b6b7516f12b32228 (patch)
tree02a300dcd882e8ee1d921345250dbe48702da0fe /diff.c
parent382f013bc40452e4c24b8698217a14ff35f6dcec (diff)
downloadgit-f506b8e8b5fb231e63b69668b6b7516f12b32228.tar.gz
git-f506b8e8b5fb231e63b69668b6b7516f12b32228.tar.xz
git log/diff: add -G<regexp> that greps in the patch text
Teach "-G<regexp>" that is similar to "-S<regexp> --pickaxe-regexp" to the "git diff" family of commands. This limits the diff queue to filepairs whose patch text actually has an added or a deleted line that matches the given regexp. Unlike "-S<regexp>", changing other parts of the line that has a substring that matches the given regexp IS counted as a change, as such a change would appear as one deletion followed by one addition in a patch text. Unlike -S (pickaxe) that is intended to be used to quickly detect a commit that changes the number of occurrences of hits between the preimage and the postimage to serve as a part of larger toolchain, this is meant to be used as the top-level Porcelain feature. The implementation unfortunately has to run "diff" twice if you are running "log" family of commands to produce patches in the final output (e.g. "git log -p" or "git format-patch"). I think we _could_ cache the result in-core if we wanted to, but that would require larger surgery to the diffcore machinery (i.e. adding an extra pointer in the filepair structure to keep a pointer to a strbuf around, stuff the textual diff to the strbuf inside diffgrep_consume(), and make use of it in later stages when it is available) and it may not be worth it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index 6631fa387..9095be16f 100644
--- a/diff.c
+++ b/diff.c
@@ -3268,12 +3268,17 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
}
else if ((argcount = short_opt('S', av, &optarg))) {
options->pickaxe = optarg;
+ options->pickaxe_opts |= DIFF_PICKAXE_KIND_S;
+ return argcount;
+ } else if ((argcount = short_opt('G', av, &optarg))) {
+ options->pickaxe = optarg;
+ options->pickaxe_opts |= DIFF_PICKAXE_KIND_G;
return argcount;
}
else if (!strcmp(arg, "--pickaxe-all"))
- options->pickaxe_opts = DIFF_PICKAXE_ALL;
+ options->pickaxe_opts |= DIFF_PICKAXE_ALL;
else if (!strcmp(arg, "--pickaxe-regex"))
- options->pickaxe_opts = DIFF_PICKAXE_REGEX;
+ options->pickaxe_opts |= DIFF_PICKAXE_REGEX;
else if ((argcount = short_opt('O', av, &optarg))) {
options->orderfile = optarg;
return argcount;