A v8 re-roll of this series. For context and v7 see: https://lore.kernel.org/git/cover-v7-00.10-00000000000-20211228T004707Z-avarab@xxxxxxxxx The v7 has not been picked up yet. The ab/grep-patterntype in Junio's tree is the v6. This v8 is rebased on "master" for a merge conflict with the now-merged lh/use-gnu-color-in-grep. Ævar Arnfjörð Bjarmason (10): grep.h: remove unused "regex_t regexp" from grep_opt log tests: check if grep_config() is called by "log"-like cmds grep tests: add missing "grep.patternType" config tests built-ins: trust the "prefix" from run_builtin() grep.c: don't pass along NULL callback value grep API: call grep_config() after grep_init() grep.h: make "grep_opt.pattern_type_option" use its enum grep.c: do "if (bool && memchr())" not "if (memchr() && bool)" grep: simplify config parsing and option parsing grep.[ch]: remove GREP_PATTERN_TYPE_UNSPECIFIED builtin/grep.c | 27 +++++----- builtin/log.c | 13 ++++- builtin/ls-tree.c | 2 +- git.c | 1 + grep.c | 126 +++++++++------------------------------------- grep.h | 34 +++++++++---- revision.c | 4 +- t/t4202-log.sh | 24 +++++++++ t/t7810-grep.sh | 68 +++++++++++++++++++++++++ 9 files changed, 168 insertions(+), 131 deletions(-) Range-diff against v7: 1: b62e6b6162a = 1: 010a2066656 grep.h: remove unused "regex_t regexp" from grep_opt 2: 0edcdb50afd = 2: e4981fa3417 log tests: check if grep_config() is called by "log"-like cmds 3: e1b4b5b77e0 = 3: 59092169e55 grep tests: add missing "grep.patternType" config tests 4: 6d91a765fd7 = 4: 331c9019a0e built-ins: trust the "prefix" from run_builtin() 5: 844b4727ca3 = 5: 25dd327b653 grep.c: don't pass along NULL callback value 6: d9cf9bf5e37 ! 6: 3c559ad006a grep API: call grep_config() after grep_init() @@ grep.c: static void std_output(struct grep_opt *opt, const void *buf, size_t siz - .pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED, - .colors = { - [GREP_COLOR_CONTEXT] = "", -- [GREP_COLOR_FILENAME] = "", +- [GREP_COLOR_FILENAME] = GIT_COLOR_MAGENTA, - [GREP_COLOR_FUNCTION] = "", -- [GREP_COLOR_LINENO] = "", -- [GREP_COLOR_COLUMNNO] = "", +- [GREP_COLOR_LINENO] = GIT_COLOR_GREEN, +- [GREP_COLOR_COLUMNNO] = GIT_COLOR_GREEN, - [GREP_COLOR_MATCH_CONTEXT] = GIT_COLOR_BOLD_RED, - [GREP_COLOR_MATCH_SELECTED] = GIT_COLOR_BOLD_RED, - [GREP_COLOR_SELECTED] = "", @@ grep.h: struct grep_opt { + .pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED, \ + .colors = { \ + [GREP_COLOR_CONTEXT] = "", \ -+ [GREP_COLOR_FILENAME] = "", \ ++ [GREP_COLOR_FILENAME] = GIT_COLOR_MAGENTA, \ + [GREP_COLOR_FUNCTION] = "", \ -+ [GREP_COLOR_LINENO] = "", \ -+ [GREP_COLOR_COLUMNNO] = "", \ ++ [GREP_COLOR_LINENO] = GIT_COLOR_GREEN, \ ++ [GREP_COLOR_COLUMNNO] = GIT_COLOR_GREEN, \ + [GREP_COLOR_MATCH_CONTEXT] = GIT_COLOR_BOLD_RED, \ + [GREP_COLOR_MATCH_SELECTED] = GIT_COLOR_BOLD_RED, \ + [GREP_COLOR_SELECTED] = "", \ 7: 57ecc5c0d65 = 7: daf873899c1 grep.h: make "grep_opt.pattern_type_option" use its enum 8: 7dbeafde26b = 8: 62650a78ea9 grep.c: do "if (bool && memchr())" not "if (memchr() && bool)" 9: c6ca39b4554 ! 9: c211bb0c69d grep: simplify config parsing and option parsing @@ grep.h: struct grep_opt { int word_regexp; - int fixed; int all_match; - #define GREP_BINARY_DEFAULT 0 - #define GREP_BINARY_NOMATCH 1 + int no_body_match; + int body_hit; @@ grep.h: struct grep_opt { int allow_textconv; int extended; 10: b764c09d2b7 ! 10: b52a0c11fa9 grep.[ch]: remove GREP_PATTERN_TYPE_UNSPECIFIED @@ grep.h: struct grep_opt { - .pattern_type_option = GREP_PATTERN_TYPE_UNSPECIFIED, \ .colors = { \ [GREP_COLOR_CONTEXT] = "", \ - [GREP_COLOR_FILENAME] = "", \ + [GREP_COLOR_FILENAME] = GIT_COLOR_MAGENTA, \ -- 2.35.0.rc1.864.g57621b115b6