Skip to content

Commit 1d75872

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce5369e commit 1d75872

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

t/lib-submodule-update.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ prolog () {
207207
# should be updated to an existing commit.
208208
reset_work_tree_to () {
209209
rm -rf submodule_update &&
210-
git clone submodule_update_repo submodule_update &&
210+
git clone --template= submodule_update_repo submodule_update &&
211211
(
212212
cd submodule_update &&
213213
rm -rf sub1 &&
@@ -902,13 +902,14 @@ test_submodule_switch_recursing_with_args () {
902902
'
903903
# ... but an ignored file is fine.
904904
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" &&
906906
prolog &&
907907
reset_work_tree_to_interested no_submodule &&
908908
(
909909
cd submodule_update &&
910910
git branch -t add_sub1 origin/add_sub1 &&
911911
: >sub1 &&
912+
mkdir .git/info &&
912913
echo sub1 >.git/info/exclude &&
913914
$command add_sub1 &&
914915
test_superproject_content origin/add_sub1 &&
@@ -951,7 +952,9 @@ test_submodule_switch_recursing_with_args () {
951952
reset_work_tree_to_interested add_sub1 &&
952953
(
953954
cd submodule_update &&
955+
rm -rf .git/modules/sub1/info &&
954956
git branch -t replace_sub1_with_file origin/replace_sub1_with_file &&
957+
mkdir .git/modules/sub1/info &&
955958
echo ignored >.git/modules/sub1/info/exclude &&
956959
: >sub1/ignored &&
957960
$command replace_sub1_with_file &&

t/t0008-ignores.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description=check-ignore
44

55
TEST_PASSES_SANITIZE_LEAK=true
6+
TEST_CREATE_REPO_NO_TEMPLATE=1
67
. ./test-lib.sh
78

89
init_vars () {
@@ -225,6 +226,7 @@ test_expect_success 'setup' '
225226
!globaltwo
226227
globalthree
227228
EOF
229+
mkdir .git/info &&
228230
cat <<-\EOF >.git/info/exclude
229231
per-repo
230232
EOF

t/t3426-rebase-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ git_rebase_interactive () {
3535
ls -1pR * >>actual &&
3636
test_cmp expect actual &&
3737
set_fake_editor &&
38+
mkdir .git/info &&
3839
echo "fake-editor.sh" >.git/info/exclude &&
3940
may_only_be_test_must_fail "$2" &&
4041
$2 git rebase -i "$1"

t/t7063-status-untracked-cache.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ test_expect_success 'core.untrackedCache is unset' '
8686
'
8787

8888
test_expect_success 'setup' '
89-
git init worktree &&
89+
git init --template= worktree &&
9090
cd worktree &&
9191
mkdir done dtwo dthree &&
9292
touch one two three done/one dtwo/two dthree/three &&
9393
test-tool chmtime =-300 one two three done/one dtwo/two dthree/three &&
9494
test-tool chmtime =-300 done dtwo dthree &&
9595
test-tool chmtime =-300 . &&
9696
git add one two done/one &&
97+
mkdir .git/info &&
9798
: >.git/info/exclude &&
9899
git update-index --untracked-cache &&
99100
test_oid_cache <<-EOF

0 commit comments

Comments
 (0)