blob: f92b3e6338302d248912c9e72665af32045702dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
#!/bin/sh
test_description='submodules handle mixed legacy and new (encoded) style gitdir paths'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-verify-submodule-gitdir-path.sh
test_expect_success 'setup: allow file protocol' '
git config --global protocol.file.allow always
'
test_expect_success 'create repo with mixed encoded and non-encoded submodules' '
git init -b main legacy-sub &&
test_commit -C legacy-sub legacy-initial &&
legacy_rev=$(git -C legacy-sub rev-parse HEAD) &&
git init -b main new-sub &&
test_commit -C new-sub new-initial &&
new_rev=$(git -C new-sub rev-parse HEAD) &&
git init -b main main &&
(
cd main &&
git submodule add ../legacy-sub legacy &&
test_commit legacy-sub &&
git config core.repositoryformatversion 1 &&
git config extensions.submoduleEncoding true &&
git submodule add ../new-sub "New Sub" &&
test_commit new
)
'
test_expect_success 'verify submodule name is properly encoded' '
verify_submodule_gitdir_path main legacy modules/legacy &&
verify_submodule_gitdir_path main "New Sub" "modules/New Sub"
'
test_expect_success 'clone from repo with both legacy and new-style submodules' '
git clone --recurse-submodules main cloned-non-encoding &&
(
cd cloned-non-encoding &&
test_path_is_dir .git/modules/legacy &&
test_path_is_dir .git/modules/"New Sub" &&
git submodule status >list &&
test_grep "$legacy_rev legacy" list &&
test_grep "$new_rev New Sub" list
) &&
git clone -c extensions.submoduleEncoding=true --recurse-submodules main cloned-encoding &&
(
cd cloned-encoding &&
test_path_is_dir .git/modules/legacy &&
test_path_is_dir ".git/modules/New Sub" &&
git submodule status >list &&
test_grep "$legacy_rev legacy" list &&
test_grep "$new_rev New Sub" list
)
'
test_expect_success 'commit and push changes to encoded submodules' '
git -C legacy-sub config receive.denyCurrentBranch updateInstead &&
git -C new-sub config receive.denyCurrentBranch updateInstead &&
git -C main config receive.denyCurrentBranch updateInstead &&
(
cd cloned-encoding &&
git -C legacy switch --track -C main origin/main &&
test_commit -C legacy second-commit &&
git -C legacy push &&
git -C "New Sub" switch --track -C main origin/main &&
test_commit -C "New Sub" second-commit &&
git -C "New Sub" push &&
# Stage and commit submodule changes in superproject
git switch --track -C main origin/main &&
git add legacy "New Sub" &&
git commit -m "update submodules" &&
# push superproject commit to main repo
git push
) &&
# update expected legacy & new submodule checksums
legacy_rev=$(git -C legacy-sub rev-parse HEAD) &&
new_rev=$(git -C new-sub rev-parse HEAD)
'
test_expect_success 'fetch mixed submodule changes and verify updates' '
(
cd main &&
# only update submodules because superproject was
# pushed into at the end of last test
git submodule update --init --recursive &&
test_path_is_dir .git/modules/legacy &&
test_path_is_dir ".git/modules/New Sub" &&
# Verify both submodules are at the expected commits
git submodule status >list &&
test_grep "$legacy_rev legacy" list &&
test_grep "$new_rev New Sub" list
)
'
test_expect_success 'setup submodules with nested git dirs' '
git init nested &&
test_commit -C nested nested &&
(
cd nested &&
cat >.gitmodules <<-EOF &&
[submodule "hippo"]
url = .
path = thing1
[submodule "hippo/hooks"]
url = .
path = thing2
EOF
git clone . thing1 &&
git clone . thing2 &&
git add .gitmodules thing1 thing2 &&
test_tick &&
git commit -m nested
)
'
test_expect_success 'git dirs of encoded sibling submodules must not be nested' '
git clone -c extensions.submoduleEncoding=true --recurse-submodules nested clone_nested &&
verify_submodule_gitdir_path clone_nested hippo modules/hippo &&
verify_submodule_gitdir_path clone_nested hippo/hooks modules/hippo%2fhooks
'
test_expect_success 'submodule git dir nesting detection must work with parallel cloning' '
git clone -c extensions.submoduleEncoding=true --recurse-submodules --jobs=2 nested clone_parallel &&
verify_submodule_gitdir_path clone_parallel hippo modules/hippo &&
verify_submodule_gitdir_path clone_parallel hippo/hooks modules/hippo%2fhooks
'
test_expect_success 'verify case-folding conflict is correctly encoded' '
git clone -c extensions.submoduleEncoding=true -c core.ignoreCase=true main cloned-folding &&
(
cd cloned-folding &&
git submodule add ../new-sub "folding" &&
test_commit lowercase &&
git submodule add ../new-sub "FoldinG" &&
test_commit uppercase
) &&
verify_submodule_gitdir_path cloned-folding "folding" "modules/folding" &&
verify_submodule_gitdir_path cloned-folding "FoldinG" "modules/%46oldin%47"
'
test_done
|