зеркало из https://github.com/microsoft/git.git
grep: add tests for grep pattern types being passed to submodules
Add testing for grep pattern types being correctly passed to submodules. The pattern "(.|.)[\d]" matches differently under fixed (not at all), and then matches different lines under basic/extended & perl regular expressions, so this change asserts that the pattern type is passed along correctly. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
5d52a30eda
Коммит
5ee6f1a21b
|
@ -313,4 +313,53 @@ test_incompatible_with_recurse_submodules ()
|
|||
test_incompatible_with_recurse_submodules --untracked
|
||||
test_incompatible_with_recurse_submodules --no-index
|
||||
|
||||
test_expect_success 'grep --recurse-submodules should pass the pattern type along' '
|
||||
# Fixed
|
||||
test_must_fail git grep -F --recurse-submodules -e "(.|.)[\d]" &&
|
||||
test_must_fail git -c grep.patternType=fixed grep --recurse-submodules -e "(.|.)[\d]" &&
|
||||
|
||||
# Basic
|
||||
git grep -G --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
cat >expect <<-\EOF &&
|
||||
a:(1|2)d(3|4)
|
||||
submodule/a:(1|2)d(3|4)
|
||||
submodule/sub/a:(1|2)d(3|4)
|
||||
EOF
|
||||
test_cmp expect actual &&
|
||||
git -c grep.patternType=basic grep --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
# Extended
|
||||
git grep -E --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
cat >expect <<-\EOF &&
|
||||
.gitmodules:[submodule "submodule"]
|
||||
.gitmodules: path = submodule
|
||||
.gitmodules: url = ./submodule
|
||||
a:(1|2)d(3|4)
|
||||
submodule/.gitmodules:[submodule "sub"]
|
||||
submodule/a:(1|2)d(3|4)
|
||||
submodule/sub/a:(1|2)d(3|4)
|
||||
EOF
|
||||
test_cmp expect actual &&
|
||||
git -c grep.patternType=extended grep --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
test_cmp expect actual &&
|
||||
git -c grep.extendedRegexp=true grep --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
# Perl
|
||||
if test_have_prereq PCRE
|
||||
then
|
||||
git grep -P --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
cat >expect <<-\EOF &&
|
||||
a:(1|2)d(3|4)
|
||||
b/b:(3|4)
|
||||
submodule/a:(1|2)d(3|4)
|
||||
submodule/sub/a:(1|2)d(3|4)
|
||||
EOF
|
||||
test_cmp expect actual &&
|
||||
git -c grep.patternType=perl grep --recurse-submodules -e "(.|.)[\d]" >actual &&
|
||||
test_cmp expect actual
|
||||
fi
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Загрузка…
Ссылка в новой задаче