Raw
1 #!/bin/sh
2
3 test_description='test protocol filtering with submodules'
4
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-proto-disable.sh
7
8 setup_ext_wrapper
9 setup_ssh_wrapper
10
11 test_expect_success 'setup repository with submodules' '
12 mkdir remote &&
13 git init remote/repo.git &&
14 (cd remote/repo.git && test_commit one) &&
15 # submodule-add should probably trust what we feed it on the cmdline,
16 # but its implementation is overly conservative.
17 GIT_ALLOW_PROTOCOL=ssh git submodule add remote:repo.git ssh-module &&
18 GIT_ALLOW_PROTOCOL=ext git submodule add "ext::fake-remote %S repo.git" ext-module &&
19 git commit -m "add submodules"
20 '
21
22 test_expect_success 'clone with recurse-submodules fails' '
23 test_must_fail git clone --recurse-submodules . dst
24 '
25
26 test_expect_success 'setup individual updates' '
27 rm -rf dst &&
28 git clone . dst &&
29 git -C dst submodule init
30 '
31
32 test_expect_success 'update of ssh allowed' '
33 git -C dst submodule update ssh-module
34 '
35
36 test_expect_success 'update of ext not allowed' '
37 test_must_fail git -C dst submodule update ext-module
38 '
39
40 test_expect_success 'user can filter protocols with GIT_ALLOW_PROTOCOL' '
41 GIT_ALLOW_PROTOCOL=ext git -C dst submodule update ext-module
42 '
43
44 test_done