log --grep: accept --basic-regexp and --perl-regexp

When we added the "--perl-regexp" option (or "-P") to "git grep", we should have done the same for the commands in the "git log" family, but somehow we forgot to do so. This corrects it, but we will reserve the short-and-sweet "-P" option for something else for now. Also introduce the "--basic-regexp" option for completeness, so that the "last one wins" principle can be used to defeat an earlier -E option, e.g. "git log -E --basic-regexp --grep='<bre>'". Note that it cannot have the short "-G" option as the option is to grep in the patch text in the context of "log" family. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 3, 2012 at 15:01 UTC 727b6fc3edacebcde0a3dc849af95bd7f5a4d4a1
2 files changed +14
Documentation/rev-list-options.txt
+10
@@ -79,6 +79,11 @@ if it is part of the log message.
79
80 Match the regexp limiting patterns without regard to letters case.
81
82 +--basic-regexp::
83 +
84 + Consider the limiting patterns to be basic regular expressions;
85 + this is the default.
86 +
87 -E::
88 --extended-regexp::
89
@@ -91,6 +96,11 @@ if it is part of the log message.
96 Consider the limiting patterns to be fixed strings (don't interpret
97 pattern as a regular expression).
98
99 +--perl-regexp::
100 +
101 + Consider the limiting patterns to be Perl-compatible regexp.
102 + Requires libpcre to be compiled in.
103 +
104 --remove-empty::
105
106 Stop when a given path disappears from the tree.
revision.c
+4
@@ -1603,6 +1603,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1603 return argcount;
1604 } else if (!strcmp(arg, "--grep-debug")) {
1605 revs->grep_filter.debug = 1;
1606 + } else if (!strcmp(arg, "--basic-regexp")) {
1607 + grep_set_pattern_type_option(GREP_PATTERN_TYPE_BRE, &revs->grep_filter);
1608 } else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
1609 grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);
1610 } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
@@ -1610,6 +1612,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1612 DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
1613 } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
1614 grep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter);
1615 + } else if (!strcmp(arg, "--perl-regexp")) {
1616 + grep_set_pattern_type_option(GREP_PATTERN_TYPE_PCRE, &revs->grep_filter);
1617 } else if (!strcmp(arg, "--all-match")) {
1618 revs->grep_filter.all_match = 1;
1619 } else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {