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.
reset_work_tree_to () {
rm -rf submodule_update &&
git clone submodule_update_repo submodule_update &&
git clone --template= submodule_update_repo submodule_update &&
(
cd submodule_update &&
rm -rf sub1 &&
@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
'
# ... but an ignored file is fine.
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 &&
reset_work_tree_to_interested no_submodule &&
(
cd submodule_update &&
git branch -t add_sub1 origin/add_sub1 &&
: >sub1 &&
mkdir .git/info &&
echo sub1 >.git/info/exclude &&
$command 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 &&
(
cd submodule_update &&
rm -rf .git/modules/sub1/info &&
git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
mkdir .git/modules/sub1/info &&
echo ignored >.git/modules/sub1/info/exclude &&
: >sub1/ignored &&
$command replace_sub1_with_file &&

View file

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

View file

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

View file

@ -86,7 +86,7 @@ test_expect_success 'core.untrackedCache is unset' '
'
test_expect_success 'setup' '
git init worktree &&
git init --template= worktree &&
cd worktree &&
mkdir done dtwo dthree &&
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 . &&
git add one two done/one &&
mkdir .git/info &&
: >.git/info/exclude &&
git update-index --untracked-cache &&
test_oid_cache <<-EOF