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>

Ævar Arnfjörð Bjarmason committed Jun 3, 2022 at 13:15 UTC 1d758728fb26f574169b7f0b420e59af1d0c3c84
4 files changed +10 -3
t/lib-submodule-update.sh
+5 -2
@@ -207,7 +207,7 @@ prolog () {
207 # should be updated to an existing commit.
208 reset_work_tree_to () {
209 rm -rf submodule_update &&
210 - git clone submodule_update_repo submodule_update &&
210 + git clone --template= submodule_update_repo submodule_update &&
211 (
212 cd submodule_update &&
213 rm -rf sub1 &&
@@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
902 '
903 # ... but an ignored file is fine.
904 test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" '
905 - test_when_finished "rm submodule_update/.git/info/exclude" &&
905 + test_when_finished "rm -rf submodule_update/.git/info" &&
906 prolog &&
907 reset_work_tree_to_interested no_submodule &&
908 (
909 cd submodule_update &&
910 git branch -t add_sub1 origin/add_sub1 &&
911 : >sub1 &&
912 + mkdir .git/info &&
913 echo sub1 >.git/info/exclude &&
914 $command add_sub1 &&
915 test_superproject_content origin/add_sub1 &&
@@ -951,7 +952,9 @@ test_submodule_switch_recursing_with_args () {
952 reset_work_tree_to_interested add_sub1 &&
953 (
954 cd submodule_update &&
955 + rm -rf .git/modules/sub1/info &&
956 git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
957 + mkdir .git/modules/sub1/info &&
958 echo ignored >.git/modules/sub1/info/exclude &&
959 : >sub1/ignored &&
960 $command replace_sub1_with_file &&
t/t0008-ignores.sh
+2
@@ -3,6 +3,7 @@
3 test_description=check-ignore
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 +TEST_CREATE_REPO_NO_TEMPLATE=1
7 . ./test-lib.sh
8
9 init_vars () {
@@ -225,6 +226,7 @@ test_expect_success 'setup' '
226 !globaltwo
227 globalthree
228 EOF
229 + mkdir .git/info &&
230 cat <<-\EOF >.git/info/exclude
231 per-repo
232 EOF
t/t3426-rebase-submodule.sh
+1
@@ -35,6 +35,7 @@ git_rebase_interactive () {
35 ls -1pR * >>actual &&
36 test_cmp expect actual &&
37 set_fake_editor &&
38 + mkdir .git/info &&
39 echo "fake-editor.sh" >.git/info/exclude &&
40 may_only_be_test_must_fail "$2" &&
41 $2 git rebase -i "$1"
t/t7063-status-untracked-cache.sh
+2 -1
@@ -86,7 +86,7 @@ test_expect_success 'core.untrackedCache is unset' '
86 '
87
88 test_expect_success 'setup' '
89 - git init worktree &&
89 + git init --template= worktree &&
90 cd worktree &&
91 mkdir done dtwo dthree &&
92 touch one two three done/one dtwo/two dthree/three &&
@@ -94,6 +94,7 @@ test_expect_success 'setup' '
94 test-tool chmtime =-300 done dtwo dthree &&
95 test-tool chmtime =-300 . &&
96 git add one two done/one &&
97 + mkdir .git/info &&
98 : >.git/info/exclude &&
99 git update-index --untracked-cache &&
100 test_oid_cache <<-EOF