t/t5NNN: 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 225d2d50ccef4baae410a96b9dc9e3978d164826
8 files changed +19
t/t5510-fetch.sh
+1
@@ -627,6 +627,7 @@ test_expect_success 'fetch.writeCommitGraph' '
627 '
628
629 test_expect_success 'fetch.writeCommitGraph with submodules' '
630 + test_config_global protocol.file.allow always &&
631 git clone dups super &&
632 (
633 cd super &&
t/t5526-fetch-submodules.sh
+1
@@ -35,6 +35,7 @@ add_upstream_commit() {
35 }
36
37 test_expect_success setup '
38 + git config --global protocol.file.allow always &&
39 mkdir deepsubmodule &&
40 (
41 cd deepsubmodule &&
t/t5545-push-options.sh
+1
@@ -113,6 +113,7 @@ test_expect_success 'push options and submodules' '
113 test_commit -C parent one &&
114 git -C parent push --mirror up &&
115
116 + test_config_global protocol.file.allow always &&
117 git -C parent submodule add ../upstream workbench &&
118 git -C parent/workbench remote add up ../../upstream &&
119 git -C parent commit -m "add submodule" &&
t/t5572-pull-submodule.sh
+4
@@ -46,6 +46,10 @@ KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
46 KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES=1
47 test_submodule_switch_func "git_pull_noff"
48
49 +test_expect_success 'setup' '
50 + git config --global protocol.file.allow always
51 +'
52 +
53 test_expect_success 'pull --recurse-submodule setup' '
54 test_create_repo child &&
55 test_commit -C child bar &&
t/t5601-clone.sh
+1
@@ -738,6 +738,7 @@ test_expect_success 'batch missing blob request does not inadvertently try to fe
738 echo aa >server/a &&
739 echo bb >server/b &&
740 # Also add a gitlink pointing to an arbitrary repository
741 + test_config_global protocol.file.allow always &&
742 git -C server submodule add "$(pwd)/repo_for_submodule" c &&
743 git -C server add a b c &&
744 git -C server commit -m x &&
t/t5614-clone-submodules-shallow.sh
+8
@@ -24,6 +24,7 @@ test_expect_success 'setup' '
24
25 test_expect_success 'nonshallow clone implies nonshallow submodule' '
26 test_when_finished "rm -rf super_clone" &&
27 + test_config_global protocol.file.allow always &&
28 git clone --recurse-submodules "file://$pwd/." super_clone &&
29 git -C super_clone log --oneline >lines &&
30 test_line_count = 3 lines &&
@@ -33,6 +34,7 @@ test_expect_success 'nonshallow clone implies nonshallow submodule' '
34
35 test_expect_success 'shallow clone with shallow submodule' '
36 test_when_finished "rm -rf super_clone" &&
37 + test_config_global protocol.file.allow always &&
38 git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
39 git -C super_clone log --oneline >lines &&
40 test_line_count = 2 lines &&
@@ -42,6 +44,7 @@ test_expect_success 'shallow clone with shallow submodule' '
44
45 test_expect_success 'shallow clone does not imply shallow submodule' '
46 test_when_finished "rm -rf super_clone" &&
47 + test_config_global protocol.file.allow always &&
48 git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
49 git -C super_clone log --oneline >lines &&
50 test_line_count = 2 lines &&
@@ -51,6 +54,7 @@ test_expect_success 'shallow clone does not imply shallow submodule' '
54
55 test_expect_success 'shallow clone with non shallow submodule' '
56 test_when_finished "rm -rf super_clone" &&
57 + test_config_global protocol.file.allow always &&
58 git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone &&
59 git -C super_clone log --oneline >lines &&
60 test_line_count = 2 lines &&
@@ -60,6 +64,7 @@ test_expect_success 'shallow clone with non shallow submodule' '
64
65 test_expect_success 'non shallow clone with shallow submodule' '
66 test_when_finished "rm -rf super_clone" &&
67 + test_config_global protocol.file.allow always &&
68 git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone &&
69 git -C super_clone log --oneline >lines &&
70 test_line_count = 3 lines &&
@@ -69,6 +74,7 @@ test_expect_success 'non shallow clone with shallow submodule' '
74
75 test_expect_success 'clone follows shallow recommendation' '
76 test_when_finished "rm -rf super_clone" &&
77 + test_config_global protocol.file.allow always &&
78 git config -f .gitmodules submodule.sub.shallow true &&
79 git add .gitmodules &&
80 git commit -m "recommend shallow for sub" &&
@@ -87,6 +93,7 @@ test_expect_success 'clone follows shallow recommendation' '
93
94 test_expect_success 'get unshallow recommended shallow submodule' '
95 test_when_finished "rm -rf super_clone" &&
96 + test_config_global protocol.file.allow always &&
97 git clone --no-local "file://$pwd/." super_clone &&
98 (
99 cd super_clone &&
@@ -103,6 +110,7 @@ test_expect_success 'get unshallow recommended shallow submodule' '
110
111 test_expect_success 'clone follows non shallow recommendation' '
112 test_when_finished "rm -rf super_clone" &&
113 + test_config_global protocol.file.allow always &&
114 git config -f .gitmodules submodule.sub.shallow false &&
115 git add .gitmodules &&
116 git commit -m "recommend non shallow for sub" &&
t/t5616-partial-clone.sh
+2
@@ -171,6 +171,8 @@ test_expect_success 'partial clone with transfer.fsckobjects=1 works with submod
171 test_config -C src_with_sub uploadpack.allowfilter 1 &&
172 test_config -C src_with_sub uploadpack.allowanysha1inwant 1 &&
173
174 + test_config_global protocol.file.allow always &&
175 +
176 git -C src_with_sub submodule add "file://$(pwd)/submodule" mysub &&
177 git -C src_with_sub commit -m "commit with submodule" &&
178
t/t5617-clone-submodules-remote.sh
+1
@@ -7,6 +7,7 @@ test_description='Test cloning repos with submodules using remote-tracking branc
7 pwd=$(pwd)
8
9 test_expect_success 'setup' '
10 + git config --global protocol.file.allow always &&
11 git checkout -b master &&
12 test_commit commit1 &&
13 mkdir sub &&