A simplification and code deletion of the overly complex setup for the grep API, no behavior changes. For v3 see: https://lore.kernel.org/git/cover-v3-0.7-00000000000-20211129T143956Z-avarab@xxxxxxxxx/ As Junio notes in https://lore.kernel.org/git/xmqqbl22634q.fsf@gitster.g/ my previous 3/7 had entirely the wrong commit message for the change it was making, i.e. the code itself was correct, but I somehow got things reversed in my head when writing the explanation. That's fixed here, and for good measure I added another related test to the same commit for the same existing behavior. Ævar Arnfjörð Bjarmason (7): 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 test 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: simplify config parsing and option parsing builtin/grep.c | 27 +++++----- builtin/log.c | 13 ++++- builtin/ls-tree.c | 2 +- git.c | 1 + grep.c | 124 ++++++++-------------------------------------- grep.h | 33 ++++++++---- revision.c | 4 +- t/t4202-log.sh | 24 +++++++++ t/t7810-grep.sh | 19 +++++++ 9 files changed, 116 insertions(+), 131 deletions(-) Range-diff against v3: 1: 71ff51cb3c9 = 1: d7d232b2b52 grep.h: remove unused "regex_t regexp" from grep_opt 2: ec8e42ced1a = 2: f853d669682 log tests: check if grep_config() is called by "log"-like cmds 3: fcad1b1664b ! 3: a97b7de3a3c grep tests: add missing "grep.patternType" config test @@ Commit message Extend the grep tests to assert that setting "grep.patternType=extended" followed by "grep.patternType=default" - will behave as if "--extended-regexp" was provided, and not as - "--basic-regexp". In a subsequent commit we'll need to treat + will behave as if "--basic-regexp" was provided, and not as + "--extended-regexp". In a subsequent commit we'll need to treat "grep.patternType=default" as a special-case, but let's make sure we - don't ignore it if "grep.patternType" was set to a non-"default" value - before. + ignore it if it's being set to "default" following an earlier + non-"default" "grep.patternType" setting. + + Let's also test what happens when we have a sequence of "extended" + followed by "default" and "fixed". In that case the "fixed" should + prevail. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> @@ t/t7810-grep.sh: do + grep "a+b*c" $H ab >actual && + test_cmp expected actual + ' ++ ++ test_expect_success "grep $L with grep.patternType=[extended -> default -> fixed]" ' ++ echo "${HC}ab:a+b*c" >expected && ++ git \ ++ -c grep.patternType=extended \ ++ -c grep.patternType=default \ ++ -c grep.patternType=fixed \ ++ grep "a+b*c" $H ab >actual && ++ test_cmp expected actual ++ ' + test_expect_success "grep $L with grep.patternType=extended and grep.extendedRegexp=false" ' echo "${HC}ab:abc" >expected && 4: 854ffe8d0b9 = 4: f7d995a5a80 built-ins: trust the "prefix" from run_builtin() 5: 2536eae2c32 = 5: ab1685f0dad grep.c: don't pass along NULL callback value 6: 4e1be7c165b = 6: 8ffa22df8c7 grep API: call grep_config() after grep_init() 7: f40ab932cb1 = 7: efbd1c50b43 grep: simplify config parsing and option parsing -- 2.34.1.875.gb925cffed1e