log --grep: use the same helper to set -E/-F options as "git grep"
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>
Junio C Hamano committed
Oct 3, 2012 at 14:50 UTC
34a4ae55b260bbd1520d6a7c6718b4de2d5c7632
2 files changed
+8
-2
revision.c
+2
-2
@@ -1604,12 +1604,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1604
} else if (!strcmp(arg, "--grep-debug")) {
1605
revs->grep_filter.debug = 1;
1606
} else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
1607
- revs->grep_filter.regflags |= REG_EXTENDED;
1607
+ grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter);
1608
} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
1609
revs->grep_filter.regflags |= REG_ICASE;
1610
DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
1611
} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
1612
- revs->grep_filter.fixed = 1;
1612
+ grep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter);
1613
} else if (!strcmp(arg, "--all-match")) {
1614
revs->grep_filter.all_match = 1;
1615
} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {
t/t4202-log.sh
+6
@@ -230,6 +230,12 @@ test_expect_success 'log --grep -i' '
230
test_cmp expect actual
231
'
232
233
+test_expect_success 'log -F -E --grep=<ere> uses ere' '
234
+ echo second >expect &&
235
+ git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
236
+ test_cmp expect actual
237
+'
238
+
239
cat > expect <<EOF
240
* Second
241
* sixth