Skip to content

Commit a5c0ed3

Browse files
avargitster
authored andcommitted
grep tests: add missing "grep.patternType" config tests
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, as well as tests to check that a "grep.extendedRegexp=true" followed by a "grep.extendedRegexp=false" behaves as though "grep.extendedRegexp" wasn't provided. See [1] for the source of some of these tests, and their initial (pseudocode) implementation, and [2] for a later discussion about a breakage due to missing testing (which had been noted in [1] all along). 1. https://lore.kernel.org/git/[email protected]/ 2. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ccb1fcc commit a5c0ed3

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

t/t7810-grep.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,58 @@ do
461461
-c grep.extendedRegexp=true \
462462
-c grep.patternType=basic
463463

464+
# grep.extendedRegexp is last-one-wins
465+
test_pattern_type "$H" "$HC" "$L" BRE \
466+
-c grep.extendedRegexp=true \
467+
-c grep.extendedRegexp=false
468+
469+
# grep.patternType=basic pays no attention to grep.extendedRegexp
470+
test_pattern_type "$H" "$HC" "$L" BRE \
471+
-c grep.extendedRegexp=true \
472+
-c grep.patternType=basic \
473+
-c grep.extendedRegexp=false
474+
475+
# grep.patternType=extended pays no attention to grep.extendedRegexp
476+
test_pattern_type "$H" "$HC" "$L" ERE \
477+
-c grep.extendedRegexp=true \
478+
-c grep.patternType=extended \
479+
-c grep.extendedRegexp=false
480+
481+
# grep.extendedRegexp is used with a last-one-wins grep.patternType=default
482+
test_pattern_type "$H" "$HC" "$L" ERE \
483+
-c grep.patternType=fixed \
484+
-c grep.extendedRegexp=true \
485+
-c grep.patternType=default
486+
487+
# grep.extendedRegexp is used with earlier grep.patternType=default
488+
test_pattern_type "$H" "$HC" "$L" ERE \
489+
-c grep.extendedRegexp=false \
490+
-c grep.patternType=default \
491+
-c grep.extendedRegexp=true
492+
493+
# grep.extendedRegexp is used with a last-one-loses grep.patternType=default
494+
test_pattern_type "$H" "$HC" "$L" ERE \
495+
-c grep.extendedRegexp=false \
496+
-c grep.extendedRegexp=true \
497+
-c grep.patternType=default
498+
499+
# grep.extendedRegexp and grep.patternType are both last-one-wins independently
500+
test_pattern_type "$H" "$HC" "$L" BRE \
501+
-c grep.patternType=default \
502+
-c grep.extendedRegexp=true \
503+
-c grep.patternType=basic
504+
505+
# grep.patternType=extended and grep.patternType=default
506+
test_pattern_type "$H" "$HC" "$L" BRE \
507+
-c grep.patternType=extended \
508+
-c grep.patternType=default
509+
510+
# grep.patternType=[extended -> default -> fixed] (BRE)" '
511+
test_pattern_type "$H" "$HC" "$L" FIX \
512+
-c grep.patternType=extended \
513+
-c grep.patternType=default \
514+
-c grep.patternType=fixed
515+
464516
test_expect_success "grep --count $L" '
465517
echo ${HC}ab:3 >expected &&
466518
git grep --count -e b $H -- ab >actual &&

0 commit comments

Comments
 (0)