Skip to content

Commit 34a4ae5

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

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

revision.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,12 +1604,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
16041604
} else if (!strcmp(arg, "--grep-debug")) {
16051605
revs->grep_filter.debug = 1;
16061606
} 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);
16081608
} else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
16091609
revs->grep_filter.regflags |= REG_ICASE;
16101610
DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
16111611
} 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);
16131613
} else if (!strcmp(arg, "--all-match")) {
16141614
revs->grep_filter.all_match = 1;
16151615
} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {

t/t4202-log.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ test_expect_success 'log --grep -i' '
230230
test_cmp expect actual
231231
'
232232

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+
233239
cat > expect <<EOF
234240
* Second
235241
* sixth

0 commit comments

Comments
 (0)