Merge branch 'jc/grep-commandline-vs-configuration'
authorJunio C Hamano <gitster@pobox.com>
Thu, 4 Aug 2016 21:39:18 +0000 (14:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Aug 2016 21:39:18 +0000 (14:39 -0700)
"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

1  2 
grep.c
grep.h
revision.c
t/t4202-log.sh
diff --cc grep.c
index 394c8569db26bc0ab386ff50a76c78611f78ffde,0bc5cc17cd4551674a9812d092d911a4720015de..58d599e6475cd1472c824743ec60b00361a396c3
--- 1/grep.c
--- 2/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:
diff --cc grep.h
Simple merge
diff --cc revision.c
Simple merge
diff --cc t/t4202-log.sh
Simple merge