From 8465541e8ce8eaf16e66ab847086779768c18f2d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Jul 2016 11:43:14 -0700 Subject: grep: further simplify setting the pattern type When c5c31d33 (grep: move pattern-type bits support to top-level grep.[ch], 2012-10-03) introduced grep_commit_pattern_type() helper function, the intention was to allow the users of grep API to having to fiddle only with .pattern_type_option (which can be set to "fixed", "basic", "extended", and "pcre"), and then immediately before compiling the pattern strings for use, call grep_commit_pattern_type() to have it prepare various bits in the grep_opt structure (like .fixed, .regflags, etc.). However, grep_set_pattern_type_option() helper function the grep API internally uses were left as an external function by mistake. This function shouldn't have been made callable by the users of the API. Later when the grep API was used in revision traversal machinery, the caller then mistakenly started calling the function around 34a4ae55 (log --grep: use the same helper to set -E/-F options as "git grep", 2012-10-03), instead of setting the .pattern_type_option field and letting the grep_commit_pattern_type() to take care of the details. This caused an unnecessary bug that made a configured grep.patternType take precedence over the command line options (e.g. --basic-regexp, --fixed-strings) in "git log" family of commands. Signed-off-by: Junio C Hamano --- revision.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'revision.c') diff --git a/revision.c b/revision.c index 871812db2a..c46dca4bca 100644 --- a/revision.c +++ b/revision.c @@ -1964,16 +1964,16 @@ 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, "--basic-regexp")) { - grep_set_pattern_type_option(GREP_PATTERN_TYPE_BRE, &revs->grep_filter); + revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_BRE; } else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) { - grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, &revs->grep_filter); + revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE; } 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")) { - grep_set_pattern_type_option(GREP_PATTERN_TYPE_FIXED, &revs->grep_filter); + revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_FIXED; } else if (!strcmp(arg, "--perl-regexp")) { - grep_set_pattern_type_option(GREP_PATTERN_TYPE_PCRE, &revs->grep_filter); + revs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_PCRE; } else if (!strcmp(arg, "--all-match")) { revs->grep_filter.all_match = 1; } else if (!strcmp(arg, "--invert-grep")) { -- cgit v1.2.3