From: Junio C Hamano Date: Wed, 10 Aug 2016 18:55:29 +0000 (-0700) Subject: Merge branch 'jc/grep-commandline-vs-configuration' into maint X-Git-Tag: v2.9.3~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b163e918772736b69252053913ba5ccc24adb4d;p=git Merge branch 'jc/grep-commandline-vs-configuration' into maint "git -c grep.patternType=extended log --basic-regexp" misbehaved because the internal API to access the grep machinery was not designed well. * jc/grep-commandline-vs-configuration: grep: further simplify setting the pattern type --- 7b163e918772736b69252053913ba5ccc24adb4d diff --cc grep.c index 394c8569db,0bc5cc17cd..58d599e647 --- a/grep.c +++ b/grep.c @@@ -153,27 -151,17 +153,17 @@@ void grep_init(struct grep_opt *opt, co opt->regflags = def->regflags; opt->relative = def->relative; - strcpy(opt->color_context, def->color_context); - strcpy(opt->color_filename, def->color_filename); - strcpy(opt->color_function, def->color_function); - strcpy(opt->color_lineno, def->color_lineno); - strcpy(opt->color_match_context, def->color_match_context); - strcpy(opt->color_match_selected, def->color_match_selected); - strcpy(opt->color_selected, def->color_selected); - strcpy(opt->color_sep, def->color_sep); + color_set(opt->color_context, def->color_context); + color_set(opt->color_filename, def->color_filename); + color_set(opt->color_function, def->color_function); + color_set(opt->color_lineno, def->color_lineno); + color_set(opt->color_match_context, def->color_match_context); + color_set(opt->color_match_selected, def->color_match_selected); + color_set(opt->color_selected, def->color_selected); + color_set(opt->color_sep, def->color_sep); } - void grep_commit_pattern_type(enum grep_pattern_type pattern_type, struct grep_opt *opt) - { - if (pattern_type != GREP_PATTERN_TYPE_UNSPECIFIED) - grep_set_pattern_type_option(pattern_type, opt); - else if (opt->pattern_type_option != GREP_PATTERN_TYPE_UNSPECIFIED) - grep_set_pattern_type_option(opt->pattern_type_option, opt); - else if (opt->extended_regexp_option) - grep_set_pattern_type_option(GREP_PATTERN_TYPE_ERE, opt); - } - - void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, struct grep_opt *opt) + static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, struct grep_opt *opt) { switch (pattern_type) { case GREP_PATTERN_TYPE_UNSPECIFIED: