t/t7NNN: 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:21 UTC 0d3beb71dad7906f576b0de9cea32164549163fe
23 files changed +62 -1
t/t7001-mv.sh
+2
@@ -307,6 +307,7 @@ test_expect_success SYMLINKS 'check moved symlink' '
307 rm -f moved symlink
308
309 test_expect_success 'setup submodule' '
310 + test_config_global protocol.file.allow always &&
311 git commit -m initial &&
312 git reset --hard &&
313 git submodule add ./. sub &&
@@ -513,6 +514,7 @@ test_expect_success 'moving a submodule in nested directories' '
514 '
515
516 test_expect_success 'moving nested submodules' '
517 + test_config_global protocol.file.allow always &&
518 git commit -am "cleanup commit" &&
519 mkdir sub_nested_nested &&
520 (cd sub_nested_nested &&
t/t7064-wtstatus-pv2.sh
+1
@@ -462,6 +462,7 @@ test_expect_success 'create and add submodule, submodule appears clean (A. S...)
462 git checkout initial-branch &&
463 git clone . sub_repo &&
464 git clone . super_repo &&
465 + test_config_global protocol.file.allow always &&
466 ( cd super_repo &&
467 git submodule add ../sub_repo sub1 &&
468
t/t7300-clean.sh
+1
@@ -480,6 +480,7 @@ test_expect_success 'should not clean submodules' '
480 git init &&
481 test_commit msg hello.world
482 ) &&
483 + test_config_global protocol.file.allow always &&
484 git submodule add ./repo/.git sub1 &&
485 git commit -m "sub1" &&
486 git branch before_sub2 &&
t/t7400-submodule-basic.sh
+4
@@ -11,6 +11,10 @@ subcommands of git submodule.
11
12 . ./test-lib.sh
13
14 +test_expect_success 'setup - enable local submodules' '
15 + git config --global protocol.file.allow always
16 +'
17 +
18 test_expect_success 'submodule deinit works on empty repository' '
19 git submodule deinit --all
20 '
t/t7403-submodule-sync.sh
+2
@@ -11,6 +11,8 @@ These tests exercise the "git submodule sync" subcommand.
11 . ./test-lib.sh
12
13 test_expect_success setup '
14 + git config --global protocol.file.allow always &&
15 +
16 echo file >file &&
17 git add file &&
18 test_tick &&
t/t7406-submodule-update.sh
+1
@@ -22,6 +22,7 @@ compare_head()
22
23
24 test_expect_success 'setup a submodule tree' '
25 + git config --global protocol.file.allow always &&
26 echo file > file &&
27 git add file &&
28 test_tick &&
t/t7407-submodule-foreach.sh
+1
@@ -13,6 +13,7 @@ that are currently checked out.
13
14
15 test_expect_success 'setup a submodule tree' '
16 + git config --global protocol.file.allow always &&
17 echo file > file &&
18 git add file &&
19 test_tick &&
t/t7408-submodule-reference.sh
+4
@@ -17,6 +17,10 @@ test_alternate_is_used () {
17 test_cmp expect actual
18 }
19
20 +test_expect_success 'setup' '
21 + git config --global protocol.file.allow always
22 +'
23 +
24 test_expect_success 'preparing first repository' '
25 test_create_repo A &&
26 (
t/t7409-submodule-detached-work-tree.sh
+4
@@ -12,6 +12,10 @@ on detached working trees
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
14
15 +test_expect_success 'setup' '
16 + git config --global protocol.file.allow always
17 +'
18 +
19 test_expect_success 'submodule on detached working tree' '
20 git init --bare remote &&
21 test_create_repo bundle1 &&
t/t7411-submodule-config.sh
+3
@@ -12,6 +12,9 @@ from the database and from the worktree works.
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
14
15 +test_expect_success 'setup' '
16 + git config --global protocol.file.allow always
17 +'
18 test_expect_success 'submodule config cache setup' '
19 mkdir submodule &&
20 (cd submodule &&
t/t7413-submodule-is-active.sh
+1
@@ -9,6 +9,7 @@ submodules which are "active" and interesting to the user.
9 . ./test-lib.sh
10
11 test_expect_success 'setup' '
12 + git config --global protocol.file.allow always &&
13 git init sub &&
14 test_commit -C sub initial &&
15 git init super &&
t/t7414-submodule-mistakes.sh
+2 -1
@@ -30,7 +30,8 @@ test_expect_success 'no warning when updating entry' '
30
31 test_expect_success 'submodule add does not warn' '
32 test_when_finished "git rm -rf submodule .gitmodules" &&
33 - git submodule add ./embed submodule 2>stderr &&
33 + git -c protocol.file.allow=always \
34 + submodule add ./embed submodule 2>stderr &&
35 test_i18ngrep ! warning stderr
36 '
37
t/t7415-submodule-names.sh
+4
@@ -8,6 +8,10 @@ real-world setup that confirms we catch this in practice.
8 . ./test-lib.sh
9 . "$TEST_DIRECTORY"/lib-pack.sh
10
11 +test_expect_success 'setup' '
12 + git config --global protocol.file.allow always
13 +'
14 +
15 test_expect_success 'check names' '
16 cat >expect <<-\EOF &&
17 valid
t/t7416-submodule-dash-url.sh
+4
@@ -3,6 +3,10 @@
3 test_description='check handling of disallowed .gitmodule urls'
4 . ./test-lib.sh
5
6 +test_expect_success 'setup' '
7 + git config --global protocol.file.allow always
8 +'
9 +
10 test_expect_success 'create submodule with protected dash in url' '
11 git init upstream &&
12 git -C upstream commit --allow-empty -m base &&
t/t7417-submodule-path-url.sh
+4
@@ -3,6 +3,10 @@
3 test_description='check handling of .gitmodule path with dash'
4 . ./test-lib.sh
5
6 +test_expect_success 'setup' '
7 + git config --global protocol.file.allow always
8 +'
9 +
10 test_expect_success 'create submodule with dash in path' '
11 git init upstream &&
12 git -C upstream commit --allow-empty -m base &&
t/t7418-submodule-sparse-gitmodules.sh
+4
@@ -14,6 +14,10 @@ also by committing .gitmodules and then just removing it from the filesystem.
14
15 . ./test-lib.sh
16
17 +test_expect_success 'setup' '
18 + git config --global protocol.file.allow always
19 +'
20 +
21 test_expect_success 'sparse checkout setup which hides .gitmodules' '
22 git init upstream &&
23 git init submodule &&
t/t7419-submodule-set-branch.sh
+4
@@ -12,6 +12,10 @@ as expected.
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
14
15 +test_expect_success 'setup' '
16 + git config --global protocol.file.allow always
17 +'
18 +
19 test_expect_success 'submodule config cache setup' '
20 mkdir submodule &&
21 (cd submodule &&
t/t7420-submodule-set-url.sh
+4
@@ -12,6 +12,10 @@ as expected.
12 TEST_NO_CREATE_REPO=1
13 . ./test-lib.sh
14
15 +test_expect_success 'setup' '
16 + git config --global protocol.file.allow always
17 +'
18 +
19 test_expect_success 'submodule config cache setup' '
20 mkdir submodule &&
21 (
t/t7421-submodule-summary-add.sh
+4
@@ -12,6 +12,10 @@ while making sure to add submodules using `git submodule add` instead of
12
13 . ./test-lib.sh
14
15 +test_expect_success 'setup' '
16 + git config --global protocol.file.allow always
17 +'
18 +
19 test_expect_success 'summary test environment setup' '
20 git init sm &&
21 test_commit -C sm "add file" file file-content file-tag &&
t/t7506-status-submodule.sh
+2
@@ -251,6 +251,7 @@ test_expect_success 'status with merge conflict in .gitmodules' '
251 test_create_repo_with_commit sub1 &&
252 test_tick &&
253 test_create_repo_with_commit sub2 &&
254 + test_config_global protocol.file.allow always &&
255 (
256 cd super &&
257 prev=$(git rev-parse HEAD) &&
@@ -326,6 +327,7 @@ test_expect_success 'diff --submodule with merge conflict in .gitmodules' '
327 # sub2 will have an untracked file
328 # sub3 will have an untracked repository
329 test_expect_success 'setup superproject with untracked file in nested submodule' '
330 + test_config_global protocol.file.allow always &&
331 (
332 cd super &&
333 git clean -dfx &&
t/t7507-commit-verbose.sh
+1
@@ -74,6 +74,7 @@ test_expect_success 'diff in message is retained with -v' '
74
75 test_expect_success 'submodule log is stripped out too with -v' '
76 git config diff.submodule log &&
77 + test_config_global protocol.file.allow always &&
78 git submodule add ./. sub &&
79 git commit -m "sub added" &&
80 (
t/t7800-difftool.sh
+1
@@ -626,6 +626,7 @@ test_expect_success 'difftool --no-symlinks detects conflict ' '
626
627 test_expect_success 'difftool properly honors gitlink and core.worktree' '
628 test_when_finished rm -rf submod/ule &&
629 + test_config_global protocol.file.allow always &&
630 git submodule add ./. submod/ule &&
631 test_config -C submod/ule diff.tool checktrees &&
632 test_config -C submod/ule difftool.checktrees.cmd '\''
t/t7814-grep-recurse-submodules.sh
+4
@@ -193,6 +193,7 @@ test_expect_success !MINGW 'grep recurse submodule colon in name' '
193 git -C "su:b" commit -m "add fi:le" &&
194 test_tick &&
195
196 + test_config_global protocol.file.allow always &&
197 git -C parent submodule add "../su:b" "su:b" &&
198 git -C parent commit -m "add submodule" &&
199 test_tick &&
@@ -227,6 +228,7 @@ test_expect_success 'grep history with moved submoules' '
228 git -C sub commit -m "add file" &&
229 test_tick &&
230
231 + test_config_global protocol.file.allow always &&
232 git -C parent submodule add ../sub dir/sub &&
233 git -C parent commit -m "add submodule" &&
234 test_tick &&
@@ -271,6 +273,7 @@ test_expect_success 'grep using relative path' '
273 mkdir parent/src &&
274 echo "(1|2)d(3|4)" >parent/src/file2 &&
275 git -C parent add src/file2 &&
276 + test_config_global protocol.file.allow always &&
277 git -C parent submodule add ../sub &&
278 git -C parent commit -m "add files and submodule" &&
279 test_tick &&
@@ -313,6 +316,7 @@ test_expect_success 'grep from a subdir' '
316 mkdir parent/src &&
317 echo "(1|2)d(3|4)" >parent/src/file &&
318 git -C parent add src/file &&
319 + test_config_global protocol.file.allow always &&
320 git -C parent submodule add ../sub src/sub &&
321 git -C parent submodule add ../sub sub &&
322 git -C parent commit -m "add files and submodules" &&