tests: don't assume a .git/info for .git/info/exclude

Change those tests that assumed that a .git/info directory would be
created for them when writing .git/info/exclude to explicitly create
the directory by setting "TEST_CREATE_REPO_NO_TEMPLATE=1" before
sourcing test-lib.sh, and using the "--template=" argument to "git
clone" and "git init".

In the case of ".git/modules/sub1/info" we deviate from the
established pattern in this and preceding commits of passing a
"--template=" and doing a "mkdir .git/info".

In that case "git checkout" will run the "submodule--helper clone",
and both e.g. "git submodule update --init" and "git checkout" do not
have a way to pass down options to the eventual "git init" or "git
clone". Let's instead assume that the submodule was populated with our
default templates, remove them, and then run the "mkdir".

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2022-06-03 13:15:08 +02:00
committed by Junio C Hamano
parent ce5369e3ef
commit 1d758728fb
4 changed files with 10 additions and 3 deletions

View File

@ -207,7 +207,7 @@ prolog () {
# should be updated to an existing commit. # should be updated to an existing commit.
reset_work_tree_to () { reset_work_tree_to () {
rm -rf submodule_update && rm -rf submodule_update &&
git clone submodule_update_repo submodule_update && git clone --template= submodule_update_repo submodule_update &&
( (
cd submodule_update && cd submodule_update &&
rm -rf sub1 && rm -rf sub1 &&
@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
' '
# ... but an ignored file is fine. # ... but an ignored file is fine.
test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" ' test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" '
test_when_finished "rm submodule_update/.git/info/exclude" && test_when_finished "rm -rf submodule_update/.git/info" &&
prolog && prolog &&
reset_work_tree_to_interested no_submodule && reset_work_tree_to_interested no_submodule &&
( (
cd submodule_update && cd submodule_update &&
git branch -t add_sub1 origin/add_sub1 && git branch -t add_sub1 origin/add_sub1 &&
: >sub1 && : >sub1 &&
mkdir .git/info &&
echo sub1 >.git/info/exclude && echo sub1 >.git/info/exclude &&
$command add_sub1 && $command add_sub1 &&
test_superproject_content origin/add_sub1 && test_superproject_content origin/add_sub1 &&
@ -951,7 +952,9 @@ test_submodule_switch_recursing_with_args () {
reset_work_tree_to_interested add_sub1 && reset_work_tree_to_interested add_sub1 &&
( (
cd submodule_update && cd submodule_update &&
rm -rf .git/modules/sub1/info &&
git branch -t replace_sub1_with_file origin/replace_sub1_with_file && git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
mkdir .git/modules/sub1/info &&
echo ignored >.git/modules/sub1/info/exclude && echo ignored >.git/modules/sub1/info/exclude &&
: >sub1/ignored && : >sub1/ignored &&
$command replace_sub1_with_file && $command replace_sub1_with_file &&

View File

@ -3,6 +3,7 @@
test_description=check-ignore test_description=check-ignore
TEST_PASSES_SANITIZE_LEAK=true TEST_PASSES_SANITIZE_LEAK=true
TEST_CREATE_REPO_NO_TEMPLATE=1
. ./test-lib.sh . ./test-lib.sh
init_vars () { init_vars () {
@ -225,6 +226,7 @@ test_expect_success 'setup' '
!globaltwo !globaltwo
globalthree globalthree
EOF EOF
mkdir .git/info &&
cat <<-\EOF >.git/info/exclude cat <<-\EOF >.git/info/exclude
per-repo per-repo
EOF EOF

View File

@ -35,6 +35,7 @@ git_rebase_interactive () {
ls -1pR * >>actual && ls -1pR * >>actual &&
test_cmp expect actual && test_cmp expect actual &&
set_fake_editor && set_fake_editor &&
mkdir .git/info &&
echo "fake-editor.sh" >.git/info/exclude && echo "fake-editor.sh" >.git/info/exclude &&
may_only_be_test_must_fail "$2" && may_only_be_test_must_fail "$2" &&
$2 git rebase -i "$1" $2 git rebase -i "$1"

View File

@ -86,7 +86,7 @@ test_expect_success 'core.untrackedCache is unset' '
' '
test_expect_success 'setup' ' test_expect_success 'setup' '
git init worktree && git init --template= worktree &&
cd worktree && cd worktree &&
mkdir done dtwo dthree && mkdir done dtwo dthree &&
touch one two three done/one dtwo/two dthree/three && touch one two three done/one dtwo/two dthree/three &&
@ -94,6 +94,7 @@ test_expect_success 'setup' '
test-tool chmtime =-300 done dtwo dthree && test-tool chmtime =-300 done dtwo dthree &&
test-tool chmtime =-300 . && test-tool chmtime =-300 . &&
git add one two done/one && git add one two done/one &&
mkdir .git/info &&
: >.git/info/exclude && : >.git/info/exclude &&
git update-index --untracked-cache && git update-index --untracked-cache &&
test_oid_cache <<-EOF test_oid_cache <<-EOF