提交 34a4ae55 编写于 作者: J Junio C Hamano

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: NJunio C Hamano <gitster@pobox.com>
上级 918d4e1c
...@@ -1604,12 +1604,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg ...@@ -1604,12 +1604,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
} else if (!strcmp(arg, "--grep-debug")) { } else if (!strcmp(arg, "--grep-debug")) {
revs->grep_filter.debug = 1; revs->grep_filter.debug = 1;
} else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) { } 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")) { } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
revs->grep_filter.regflags |= REG_ICASE; revs->grep_filter.regflags |= REG_ICASE;
DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE); DIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);
} else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) { } 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")) { } else if (!strcmp(arg, "--all-match")) {
revs->grep_filter.all_match = 1; revs->grep_filter.all_match = 1;
} else if ((argcount = parse_long_opt("encoding", argv, &optarg))) { } else if ((argcount = parse_long_opt("encoding", argv, &optarg))) {
......
...@@ -230,6 +230,12 @@ test_expect_success 'log --grep -i' ' ...@@ -230,6 +230,12 @@ test_expect_success 'log --grep -i' '
test_cmp expect actual 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 cat > expect <<EOF
* Second * Second
* sixth * sixth
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册