git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] log --grep: accept --basic-regexp and --perl-regexp

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 4, 2012, 01:33 UTC
Message-ID
<1349314419-8397-5-git-send-email-gitster@pobox.com>
In-Reply-To
<1349314419-8397-1-git-send-email-gitster@pobox.com>

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.

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>
---
 revision.c | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/revision.c b/revision.c
index 7f5e53b..0f73512 100644
--- a/revision.c
+++ b/revision.c
@@ -1603,6 +1603,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 		return argcount;
 	} else if (!strcmp(arg, "--grep-debug")) {
 		revs->grep_filter.debug = 1;
+	} else if (!strcmp(arg, "--basic-regexp")) {
+		grep_set_pattern_type_option(GREP_PATTERN_TYPE_BRE, &revs->grep_filter);
 	} else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
 		grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);
 	} 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
 		DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
 	} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
 		grep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter);
+	} else if (!strcmp(arg, "--perl-regexp") || !strcmp(arg, "-P")) {
+		grep_set_pattern_type_option(GREP_PATTERN_TYPE_PCRE, &revs->grep_filter);
 	} else if (!strcmp(arg, "--all-match")) {
 		revs->grep_filter.all_match = 1;
 	} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {
-- 
1.8.0.rc0.57.g712528f
Previous: Jeff KingNext: Jeff King
Message 11 of 23 in “[ANNOUNCE] Git v1.8.0-rc0”
  1. Junio C HamanoOct 1, 2012
  2. grep.patternType (was: Re: [ANNOUNCE] Git v1.8.0-rc0)Junio C Hamano, Oct 3, 2012
  3. Junio C HamanoOct 3, 2012
  4. Michal KiedrowiczOct 4, 2012
  5. J SmithOct 5, 2012
  6. 0/6 Tying loose ends of extended "grep"Junio C Hamano, Oct 4, 2012
  7. 1/6 grep: move configuration support to top-level grep.[ch]Junio C Hamano, Oct 4, 2012
  8. 2/6 grep: move pattern-type bits support to top-level grep.[ch]Junio C Hamano, Oct 4, 2012
  9. 3/6 log --grep: use the same helper to set -E/-F options as "git grep"Junio C Hamano, Oct 4, 2012
  10. Jeff KingOct 4, 2012
  11. 4/6 log --grep: accept --basic-regexp and --perl-regexpJunio C Hamano, Oct 4, 2012
  12. Jeff KingOct 4, 2012
  13. Junio C HamanoOct 4, 2012
  14. 5/6 log: pass rev_info to git_log_config()Junio C Hamano, Oct 4, 2012
  15. Junio C HamanoOct 4, 2012
  16. Junio C HamanoOct 5, 2012
  17. Jeff KingOct 5, 2012
  18. Junio C HamanoOct 5, 2012
  19. 6/6 log --grep: honor grep.patterntype etc. configuration variablesJunio C Hamano, Oct 4, 2012
  20. Jeff KingOct 4, 2012
  21. Junio C HamanoOct 4, 2012
  22. Jeff KingOct 4, 2012
  23. Junio C HamanoOct 4, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.