Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > Extend the grep tests to assert that setting > "grep.patternType=extended" followed by "grep.patternType=default" > 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 > 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. The grep.patternType configuration variable has the "last one wins" semantics just all the usual configuration variable, but the meaning of the variable when it is set to "default" depends on the value set to grep.extendedRegexp variable. If you rewrite with the above understanding, what you wrote will become a lot more concise. Extend the grep tests to assert that grep.patternType is the usual "last one wins" variable, and specifically, setting it to "default" has the same meaning as setting it to "basic" when grep.extendedRegexp is not set (or set to false). > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> > --- > t/t7810-grep.sh | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh > index 6b6423a07c3..113902c3bda 100755 > --- a/t/t7810-grep.sh > +++ b/t/t7810-grep.sh > @@ -451,6 +451,25 @@ do > test_cmp expected actual > ' > > + test_expect_success "grep $L with grep.patternType=extended and grep.patternType=default" ' > + echo "${HC}ab:a+bc" >expected && > + git \ > + -c grep.patternType=extended \ > + -c grep.patternType=default \ > + 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 && And from that point of view, I think the second new test has much less value than a possible alternative to ensure grep.patternType set to fixed and then default behaves like setting it to extended when grep.extendedRegexp is set to true. As written, this is just testing that the variable we designed and know to be "last one wins" behaves as one once more. > + test_cmp expected actual > + ' > + > test_expect_success "grep $L with grep.patternType=extended and grep.extendedRegexp=false" ' > echo "${HC}ab:abc" >expected && > git \