]>
Commit | Line | Data |
---|---|---|
4c691016 BA |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test cloning repos with submodules using remote-tracking branches' | |
4 | ||
95cf2c01 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
dd4143e7 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
4c691016 BA |
9 | . ./test-lib.sh |
10 | ||
11 | pwd=$(pwd) | |
12 | ||
13 | test_expect_success 'setup' ' | |
225d2d50 | 14 | git config --global protocol.file.allow always && |
95cf2c01 | 15 | git checkout -b main && |
4c691016 BA |
16 | test_commit commit1 && |
17 | mkdir sub && | |
18 | ( | |
19 | cd sub && | |
20 | git init && | |
21 | test_commit subcommit1 && | |
132f600b ES |
22 | git tag sub_when_added_to_super && |
23 | git branch other | |
4c691016 BA |
24 | ) && |
25 | git submodule add "file://$pwd/sub" sub && | |
26 | git commit -m "add submodule" && | |
27 | ( | |
28 | cd sub && | |
29 | test_commit subcommit2 | |
30 | ) | |
31 | ' | |
32 | ||
f05da2b4 JS |
33 | # bare clone giving "srv.bare" for use as our server. |
34 | test_expect_success 'setup bare clone for server' ' | |
35 | git clone --bare "file://$(pwd)/." srv.bare && | |
36 | git -C srv.bare config --local uploadpack.allowfilter 1 && | |
37 | git -C srv.bare config --local uploadpack.allowanysha1inwant 1 | |
38 | ' | |
39 | ||
4c691016 BA |
40 | test_expect_success 'clone with --no-remote-submodules' ' |
41 | test_when_finished "rm -rf super_clone" && | |
42 | git clone --recurse-submodules --no-remote-submodules "file://$pwd/." super_clone && | |
43 | ( | |
44 | cd super_clone/sub && | |
45 | git diff --exit-code sub_when_added_to_super | |
46 | ) | |
47 | ' | |
48 | ||
49 | test_expect_success 'clone with --remote-submodules' ' | |
50 | test_when_finished "rm -rf super_clone" && | |
51 | git clone --recurse-submodules --remote-submodules "file://$pwd/." super_clone && | |
52 | ( | |
53 | cd super_clone/sub && | |
95cf2c01 | 54 | git diff --exit-code remotes/origin/main |
4c691016 BA |
55 | ) |
56 | ' | |
57 | ||
58 | test_expect_success 'check the default is --no-remote-submodules' ' | |
59 | test_when_finished "rm -rf super_clone" && | |
60 | git clone --recurse-submodules "file://$pwd/." super_clone && | |
61 | ( | |
62 | cd super_clone/sub && | |
63 | git diff --exit-code sub_when_added_to_super | |
64 | ) | |
65 | ' | |
66 | ||
132f600b ES |
67 | test_expect_success 'clone with --single-branch' ' |
68 | test_when_finished "rm -rf super_clone" && | |
69 | git clone --recurse-submodules --single-branch "file://$pwd/." super_clone && | |
70 | ( | |
71 | cd super_clone/sub && | |
95cf2c01 | 72 | git rev-parse --verify origin/main && |
132f600b ES |
73 | test_must_fail git rev-parse --verify origin/other |
74 | ) | |
75 | ' | |
76 | ||
f05da2b4 JS |
77 | # do basic partial clone from "srv.bare" |
78 | # confirm partial clone was registered in the local config for super and sub. | |
79 | test_expect_success 'clone with --filter' ' | |
80 | git clone --recurse-submodules \ | |
81 | --filter blob:none --also-filter-submodules \ | |
82 | "file://$pwd/srv.bare" super_clone && | |
83 | test_cmp_config -C super_clone true remote.origin.promisor && | |
84 | test_cmp_config -C super_clone blob:none remote.origin.partialclonefilter && | |
85 | test_cmp_config -C super_clone/sub true remote.origin.promisor && | |
86 | test_cmp_config -C super_clone/sub blob:none remote.origin.partialclonefilter | |
87 | ' | |
88 | ||
89 | # check that clone.filterSubmodules works (--also-filter-submodules can be | |
90 | # omitted) | |
91 | test_expect_success 'filters applied with clone.filterSubmodules' ' | |
92 | test_config_global clone.filterSubmodules true && | |
93 | git clone --recurse-submodules --filter blob:none \ | |
94 | "file://$pwd/srv.bare" super_clone2 && | |
95 | test_cmp_config -C super_clone2 true remote.origin.promisor && | |
96 | test_cmp_config -C super_clone2 blob:none remote.origin.partialclonefilter && | |
97 | test_cmp_config -C super_clone2/sub true remote.origin.promisor && | |
98 | test_cmp_config -C super_clone2/sub blob:none remote.origin.partialclonefilter | |
99 | ' | |
100 | ||
101 | test_expect_success '--no-also-filter-submodules overrides clone.filterSubmodules=true' ' | |
102 | test_config_global clone.filterSubmodules true && | |
103 | git clone --recurse-submodules --filter blob:none \ | |
104 | --no-also-filter-submodules \ | |
105 | "file://$pwd/srv.bare" super_clone3 && | |
106 | test_cmp_config -C super_clone3 true remote.origin.promisor && | |
107 | test_cmp_config -C super_clone3 blob:none remote.origin.partialclonefilter && | |
108 | test_cmp_config -C super_clone3/sub false --default false remote.origin.promisor | |
109 | ' | |
110 | ||
4c691016 | 111 | test_done |