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 <me@ttaylorr.com>

Taylor Blau committed Jul 29, 2022 at 15:20 UTC 99f4abb8dae4c9c604e5d5cf255958bbe537b928
3 files changed +8 -2
t/t2400-worktree-add.sh
+2
@@ -597,6 +597,7 @@ test_expect_success '"add" should not fail because of another bad worktree' '
597 '
598
599 test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' '
600 + test_config_global protocol.file.allow always &&
601 test_create_repo submodule &&
602 test_commit -C submodule first &&
603 test_create_repo project &&
@@ -612,6 +613,7 @@ test_expect_success '"add" with uninitialized submodule, with submodule.recurse
613 '
614
615 test_expect_success '"add" with initialized submodule, with submodule.recurse unset' '
616 + test_config_global protocol.file.allow always &&
617 git -C project-clone submodule update --init &&
618 git -C project-clone worktree add ../project-4
619 '
t/t2403-worktree-move.sh
+5 -2
@@ -138,7 +138,8 @@ test_expect_success 'move a repo with uninitialized submodule' '
138 (
139 cd withsub &&
140 test_commit initial &&
141 - git submodule add "$PWD"/.git sub &&
141 + git -c protocol.file.allow=always \
142 + submodule add "$PWD"/.git sub &&
143 git commit -m withsub &&
144 git worktree add second HEAD &&
145 git worktree move second third
@@ -148,7 +149,7 @@ test_expect_success 'move a repo with uninitialized submodule' '
149 test_expect_success 'not move a repo with initialized submodule' '
150 (
151 cd withsub &&
151 - git -C third submodule update &&
152 + git -c protocol.file.allow=always -C third submodule update &&
153 test_must_fail git worktree move third forth
154 )
155 '
@@ -227,6 +228,7 @@ test_expect_success 'remove cleans up .git/worktrees when empty' '
228 '
229
230 test_expect_success 'remove a repo with uninitialized submodule' '
231 + test_config_global protocol.file.allow always &&
232 (
233 cd withsub &&
234 git worktree add to-remove HEAD &&
@@ -235,6 +237,7 @@ test_expect_success 'remove a repo with uninitialized submodule' '
237 '
238
239 test_expect_success 'not remove a repo with initialized submodule' '
240 + test_config_global protocol.file.allow always &&
241 (
242 cd withsub &&
243 git worktree add to-remove HEAD &&
t/t2405-worktree-submodule.sh
+1
@@ -7,6 +7,7 @@ test_description='Combination of submodules and multiple worktrees'
7 base_path=$(pwd -P)
8
9 test_expect_success 'setup: create origin repos' '
10 + git config --global protocol.file.allow always &&
11 git init origin/sub &&
12 test_commit -C origin/sub file1 &&
13 git init origin/main &&