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

[PATCH v2 5/7] log --grep: use the same helper to set -E/-F options as "git grep"

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 10, 2012, 07:55 UTC
Message-ID
<1349855714-17008-6-git-send-email-gitster@pobox.com>
In-Reply-To
<1349855714-17008-1-git-send-email-gitster@pobox.com>

The command line option parser for "git log -F -E --grep='<ere>'" did not flip the "fixed" bit, violating the general "last option wins" principle among conflicting options.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 revision.c     | 4 ++--
 t/t4202-log.sh | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index a4a9314..68545c8 100644
--- a/revision.c
+++ b/revision.c
@@ -1604,12 +1604,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 	} else if (!strcmp(arg, "--grep-debug")) {
 		revs->grep_filter.debug = 1;
 	} else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
-		revs->grep_filter.regflags |= REG_EXTENDED;
+		grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);
 	} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
 		revs->grep_filter.regflags |= REG_ICASE;
 		DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
 	} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
-		revs->grep_filter.fixed = 1;
+		grep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter);
 	} else if (!strcmp(arg, "--all-match")) {
 		revs->grep_filter.all_match = 1;
 	} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 924ba53..e6537ab 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -230,6 +230,12 @@ test_expect_success 'log --grep -i' '
 	test_cmp expect actual
 '
 
+test_expect_success 'log -F -E --grep=<ere> uses ere' '
+	echo second >expect &&
+	git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
+	test_cmp expect actual
+'
+
 cat > expect <<EOF
 * Second
 * sixth
-- 
1.8.0.rc1.76.g5a375e6
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 11 in “Tying loose ends on grep-pcre”
  1. 0/7 Tying loose ends on grep-pcreJunio C Hamano, Oct 10, 2012
  2. 1/7 builtin/grep.c: make configuration callback more reusableJunio C Hamano, Oct 10, 2012
  3. 2/7 grep: move the configuration parsing logic to grep.[ch]Junio C Hamano, Oct 10, 2012
  4. 3/7 grep: move pattern-type bits support to top-level grep.[ch]Junio C Hamano, Oct 10, 2012
  5. 4/7 revisions: initialize revs->grep_filter using grep_init()Junio C Hamano, Oct 10, 2012
  6. 5/7 log --grep: use the same helper to set -E/-F options as "git grep"Junio C Hamano, Oct 10, 2012
  7. 6/7 log --grep: accept --basic-regexp and --perl-regexpJunio C Hamano, Oct 10, 2012
  8. 7/7 log: honor grep.* configurationJunio C Hamano, Oct 10, 2012
  9. Michael HaggertyOct 10, 2012
  10. Junio C HamanoOct 10, 2012
  11. Michael HaggertyOct 11, 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.