Skip to content

Commit 99f4abb

Browse files
committed
t/2NNNN: allow local submodules
To prepare for the default value of `protocol.file.allow` to change to "user", ensure tests that rely on local submodules can initialize them over the file protocol. Tests that only need to interact with submodules in a limited capacity have individual Git commands annotated with the appropriate configuration via `-c`. Tests that interact with submodules a handful of times use `test_config_global` instead. Test scripts that rely on submodules throughout use a `git config --global` during a setup test towards the beginning of the script. Signed-off-by: Taylor Blau <[email protected]>
1 parent 8a96dbc commit 99f4abb

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

t/t2400-worktree-add.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ test_expect_success '"add" should not fail because of another bad worktree' '
597597
'
598598

599599
test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' '
600+
test_config_global protocol.file.allow always &&
600601
test_create_repo submodule &&
601602
test_commit -C submodule first &&
602603
test_create_repo project &&
@@ -612,6 +613,7 @@ test_expect_success '"add" with uninitialized submodule, with submodule.recurse
612613
'
613614

614615
test_expect_success '"add" with initialized submodule, with submodule.recurse unset' '
616+
test_config_global protocol.file.allow always &&
615617
git -C project-clone submodule update --init &&
616618
git -C project-clone worktree add ../project-4
617619
'

t/t2403-worktree-move.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ test_expect_success 'move a repo with uninitialized submodule' '
138138
(
139139
cd withsub &&
140140
test_commit initial &&
141-
git submodule add "$PWD"/.git sub &&
141+
git -c protocol.file.allow=always \
142+
submodule add "$PWD"/.git sub &&
142143
git commit -m withsub &&
143144
git worktree add second HEAD &&
144145
git worktree move second third
@@ -148,7 +149,7 @@ test_expect_success 'move a repo with uninitialized submodule' '
148149
test_expect_success 'not move a repo with initialized submodule' '
149150
(
150151
cd withsub &&
151-
git -C third submodule update &&
152+
git -c protocol.file.allow=always -C third submodule update &&
152153
test_must_fail git worktree move third forth
153154
)
154155
'
@@ -227,6 +228,7 @@ test_expect_success 'remove cleans up .git/worktrees when empty' '
227228
'
228229

229230
test_expect_success 'remove a repo with uninitialized submodule' '
231+
test_config_global protocol.file.allow always &&
230232
(
231233
cd withsub &&
232234
git worktree add to-remove HEAD &&
@@ -235,6 +237,7 @@ test_expect_success 'remove a repo with uninitialized submodule' '
235237
'
236238

237239
test_expect_success 'not remove a repo with initialized submodule' '
240+
test_config_global protocol.file.allow always &&
238241
(
239242
cd withsub &&
240243
git worktree add to-remove HEAD &&

t/t2405-worktree-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_description='Combination of submodules and multiple worktrees'
77
base_path=$(pwd -P)
88

99
test_expect_success 'setup: create origin repos' '
10+
git config --global protocol.file.allow always &&
1011
git init origin/sub &&
1112
test_commit -C origin/sub file1 &&
1213
git init origin/main &&

0 commit comments

Comments
 (0)