diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2017-06-29 22:22:21 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-30 10:06:24 -0700 |
commit | 07a3d4117390841ed6884a9eac836918491df0a9 (patch) | |
tree | 533b2a85560776d713114c41dd693848c41593f6 /builtin | |
parent | b07ed4e532fa9492a53b7b510c45efd671f468a8 (diff) | |
download | git-07a3d4117390841ed6884a9eac836918491df0a9.tar.gz |
grep: remove regflags from the public grep_opt API
Refactor calls to the grep machinery to always pass opt.ignore_case &
opt.extended_regexp_option instead of setting the equivalent regflags
bits.
The bug fixed when making -i work with -P in commit 9e3cbc59d5 ("log:
make --regexp-ignore-case work with --perl-regexp", 2017-05-20) was
really just plastering over the code smell which this change fixes.
The reason for adding the extensive commentary here is that I
discovered some subtle complexity in implementing this that really
should be called out explicitly to future readers.
Before this change we'd rely on the difference between
`extended_regexp_option` and `regflags` to serve as a membrane between
our preliminary parsing of grep.extendedRegexp and grep.patternType,
and what we decided to do internally.
Now that those two are the same thing, it's necessary to unset
`extended_regexp_option` just before we commit in cases where both of
those config variables are set. See 84befcd0a4 ("grep: add a
grep.patternType configuration setting", 2012-08-03) for the code and
documentation related to that.
The explanation of why the if/else branches in
grep_commit_pattern_type() are ordered the way they are exists in that
commit message, but I think it's worth calling this subtlety out
explicitly with a comment for future readers.
Even though grep_commit_pattern_type() is the only caller of
grep_set_pattern_type_option() it's simpler to reset the
extended_regexp_option flag in the latter, since 2/3 branches in the
former would otherwise need to reset it, this way we can do it in one
place.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index f61a9d938b..b682966439 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -1169,8 +1169,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) if (!opt.pattern_list) die(_("no pattern given.")); - if (!opt.fixed && opt.ignore_case) - opt.regflags |= REG_ICASE; /* * We have to find "--" in a separate pass, because its presence |