Skip to content

Commit 727b6fc

Browse files
committed
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 <[email protected]>
1 parent 34a4ae5 commit 727b6fc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Documentation/rev-list-options.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ if it is part of the log message.
7979

8080
Match the regexp limiting patterns without regard to letters case.
8181

82+
--basic-regexp::
83+
84+
Consider the limiting patterns to be basic regular expressions;
85+
this is the default.
86+
8287
-E::
8388
--extended-regexp::
8489

@@ -91,6 +96,11 @@ if it is part of the log message.
9196
Consider the limiting patterns to be fixed strings (don't interpret
9297
pattern as a regular expression).
9398

99+
--perl-regexp::
100+
101+
Consider the limiting patterns to be Perl-compatible regexp.
102+
Requires libpcre to be compiled in.
103+
94104
--remove-empty::
95105

96106
Stop when a given path disappears from the tree.

revision.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,13 +1603,17 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
16031603
return argcount;
16041604
} else if (!strcmp(arg, "--grep-debug")) {
16051605
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);
16061608
} else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
16071609
grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);
16081610
} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
16091611
revs->grep_filter.regflags |= REG_ICASE;
16101612
DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
16111613
} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
16121614
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);
16131617
} else if (!strcmp(arg, "--all-match")) {
16141618
revs->grep_filter.all_match = 1;
16151619
} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {

0 commit comments

Comments
 (0)