@@ -11,216 +11,266 @@ These tests exercise the "git submodule sync" subcommand.
11
11
. ./test-lib.sh
12
12
13
13
test_expect_success setup '
14
- echo file > file &&
14
+ echo file >file &&
15
15
git add file &&
16
16
test_tick &&
17
17
git commit -m upstream &&
18
18
git clone . super &&
19
19
git clone super submodule &&
20
- (cd submodule &&
21
- git submodule add ../submodule sub-submodule &&
22
- test_tick &&
23
- git commit -m "sub-submodule"
20
+ (
21
+ cd submodule &&
22
+ git submodule add ../submodule sub-submodule &&
23
+ test_tick &&
24
+ git commit -m "sub-submodule"
24
25
) &&
25
- (cd super &&
26
- git submodule add ../submodule submodule &&
27
- test_tick &&
28
- git commit -m "submodule"
26
+ (
27
+ cd super &&
28
+ git submodule add ../submodule submodule &&
29
+ test_tick &&
30
+ git commit -m "submodule"
29
31
) &&
30
32
git clone super super-clone &&
31
- (cd super-clone && git submodule update --init --recursive) &&
33
+ (
34
+ cd super-clone &&
35
+ git submodule update --init --recursive
36
+ ) &&
32
37
git clone super empty-clone &&
33
- (cd empty-clone && git submodule init) &&
38
+ (
39
+ cd empty-clone &&
40
+ git submodule init
41
+ ) &&
34
42
git clone super top-only-clone &&
35
43
git clone super relative-clone &&
36
- (cd relative-clone && git submodule update --init --recursive) &&
44
+ (
45
+ cd relative-clone &&
46
+ git submodule update --init --recursive
47
+ ) &&
37
48
git clone super recursive-clone &&
38
- (cd recursive-clone && git submodule update --init --recursive)
49
+ (
50
+ cd recursive-clone &&
51
+ git submodule update --init --recursive
52
+ )
39
53
'
40
54
41
55
test_expect_success ' change submodule' '
42
- (cd submodule &&
43
- echo second line >> file &&
44
- test_tick &&
45
- git commit -a -m "change submodule"
56
+ (
57
+ cd submodule &&
58
+ echo second line >>file &&
59
+ test_tick &&
60
+ git commit -a -m "change submodule"
46
61
)
47
62
'
48
63
49
64
test_expect_success ' change submodule url' '
50
- (cd super &&
51
- cd submodule &&
52
- git checkout master &&
53
- git pull
65
+ (
66
+ cd super &&
67
+ cd submodule &&
68
+ git checkout master &&
69
+ git pull
54
70
) &&
55
71
mv submodule moved-submodule &&
56
- (cd moved-submodule &&
57
- git config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&
58
- test_tick &&
59
- git commit -a -m moved-sub-submodule
72
+ (
73
+ cd moved-submodule &&
74
+ git config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&
75
+ test_tick &&
76
+ git commit -a -m moved-sub-submodule
60
77
) &&
61
- (cd super &&
62
- git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
63
- test_tick &&
64
- git commit -a -m moved-submodule
78
+ (
79
+ cd super &&
80
+ git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
81
+ test_tick &&
82
+ git commit -a -m moved-submodule
65
83
)
66
84
'
67
85
68
86
test_expect_success ' "git submodule sync" should update submodule URLs' '
69
- (cd super-clone &&
70
- git pull --no-recurse-submodules &&
71
- git submodule sync
87
+ (
88
+ cd super-clone &&
89
+ git pull --no-recurse-submodules &&
90
+ git submodule sync
72
91
) &&
73
- test -d "$(cd super-clone/submodule &&
74
- git config remote.origin.url
92
+ test -d "$(
93
+ cd super-clone/submodule &&
94
+ git config remote.origin.url
75
95
)" &&
76
- test ! -d "$(cd super-clone/submodule/sub-submodule &&
77
- git config remote.origin.url
96
+ test ! -d "$(
97
+ cd super-clone/submodule/sub-submodule &&
98
+ git config remote.origin.url
78
99
)" &&
79
- (cd super-clone/submodule &&
80
- git checkout master &&
81
- git pull
100
+ (
101
+ cd super-clone/submodule &&
102
+ git checkout master &&
103
+ git pull
82
104
) &&
83
- (cd super-clone &&
84
- test -d "$(git config submodule.submodule.url)"
105
+ (
106
+ cd super-clone &&
107
+ test -d "$(git config submodule.submodule.url)"
85
108
)
86
109
'
87
110
88
111
test_expect_success ' "git submodule sync --recursive" should update all submodule URLs' '
89
- (cd super-clone &&
90
- (cd submodule &&
91
- git pull --no-recurse-submodules
92
- ) &&
93
- git submodule sync --recursive
112
+ (
113
+ cd super-clone &&
114
+ (
115
+ cd submodule &&
116
+ git pull --no-recurse-submodules
117
+ ) &&
118
+ git submodule sync --recursive
94
119
) &&
95
- test -d "$(cd super-clone/submodule &&
96
- git config remote.origin.url
120
+ test -d "$(
121
+ cd super-clone/submodule &&
122
+ git config remote.origin.url
97
123
)" &&
98
- test -d "$(cd super-clone/submodule/sub-submodule &&
99
- git config remote.origin.url
124
+ test -d "$(
125
+ cd super-clone/submodule/sub-submodule &&
126
+ git config remote.origin.url
100
127
)" &&
101
- (cd super-clone/submodule/sub-submodule &&
102
- git checkout master &&
103
- git pull
128
+ (
129
+ cd super-clone/submodule/sub-submodule &&
130
+ git checkout master &&
131
+ git pull
104
132
)
105
133
'
106
134
107
135
test_expect_success ' "git submodule sync" should update known submodule URLs' '
108
- (cd empty-clone &&
109
- git pull &&
110
- git submodule sync &&
111
- test -d "$(git config submodule.submodule.url)"
136
+ (
137
+ cd empty-clone &&
138
+ git pull &&
139
+ git submodule sync &&
140
+ test -d "$(git config submodule.submodule.url)"
112
141
)
113
142
'
114
143
115
144
test_expect_success ' "git submodule sync" should not vivify uninteresting submodule' '
116
- (cd top-only-clone &&
117
- git pull &&
118
- git submodule sync &&
119
- test -z "$(git config submodule.submodule.url)" &&
120
- git submodule sync submodule &&
121
- test -z "$(git config submodule.submodule.url)"
145
+ (
146
+ cd top-only-clone &&
147
+ git pull &&
148
+ git submodule sync &&
149
+ test -z "$(git config submodule.submodule.url)" &&
150
+ git submodule sync submodule &&
151
+ test -z "$(git config submodule.submodule.url)"
122
152
)
123
153
'
124
154
125
155
test_expect_success ' "git submodule sync" handles origin URL of the form foo' '
126
- (cd relative-clone &&
127
- git remote set-url origin foo &&
128
- git submodule sync &&
129
- (cd submodule &&
130
- #actual fails with: "cannot strip off url foo
131
- test "$(git config remote.origin.url)" = "../submodule"
132
- )
156
+ (
157
+ cd relative-clone &&
158
+ git remote set-url origin foo &&
159
+ git submodule sync &&
160
+ (
161
+ cd submodule &&
162
+ #actual fails with: "cannot strip off url foo
163
+ test "$(git config remote.origin.url)" = "../submodule"
164
+ )
133
165
)
134
166
'
135
167
136
168
test_expect_success ' "git submodule sync" handles origin URL of the form foo/bar' '
137
- (cd relative-clone &&
138
- git remote set-url origin foo/bar &&
139
- git submodule sync &&
140
- (cd submodule &&
141
- #actual foo/submodule
142
- test "$(git config remote.origin.url)" = "../foo/submodule"
143
- )
144
- (cd submodule/sub-submodule &&
145
- test "$(git config remote.origin.url)" != "../../foo/submodule"
146
- )
169
+ (
170
+ cd relative-clone &&
171
+ git remote set-url origin foo/bar &&
172
+ git submodule sync &&
173
+ (
174
+ cd submodule &&
175
+ #actual foo/submodule
176
+ test "$(git config remote.origin.url)" = "../foo/submodule"
177
+ )
178
+ (
179
+ cd submodule/sub-submodule &&
180
+ test "$(git config remote.origin.url)" != "../../foo/submodule"
181
+ )
147
182
)
148
183
'
149
184
150
185
test_expect_success ' "git submodule sync --recursive" propagates changes in origin' '
151
- (cd recursive-clone &&
152
- git remote set-url origin foo/bar &&
153
- git submodule sync --recursive &&
154
- (cd submodule &&
155
- #actual foo/submodule
156
- test "$(git config remote.origin.url)" = "../foo/submodule"
157
- )
158
- (cd submodule/sub-submodule &&
159
- test "$(git config remote.origin.url)" = "../../foo/submodule"
160
- )
186
+ (
187
+ cd recursive-clone &&
188
+ git remote set-url origin foo/bar &&
189
+ git submodule sync --recursive &&
190
+ (
191
+ cd submodule &&
192
+ #actual foo/submodule
193
+ test "$(git config remote.origin.url)" = "../foo/submodule"
194
+ )
195
+ (
196
+ cd submodule/sub-submodule &&
197
+ test "$(git config remote.origin.url)" = "../../foo/submodule"
198
+ )
161
199
)
162
200
'
163
201
164
202
test_expect_success ' "git submodule sync" handles origin URL of the form ./foo' '
165
- (cd relative-clone &&
166
- git remote set-url origin ./foo &&
167
- git submodule sync &&
168
- (cd submodule &&
169
- #actual ./submodule
170
- test "$(git config remote.origin.url)" = "../submodule"
171
- )
203
+ (
204
+ cd relative-clone &&
205
+ git remote set-url origin ./foo &&
206
+ git submodule sync &&
207
+ (
208
+ cd submodule &&
209
+ #actual ./submodule
210
+ test "$(git config remote.origin.url)" = "../submodule"
211
+ )
172
212
)
173
213
'
174
214
175
215
test_expect_success ' "git submodule sync" handles origin URL of the form ./foo/bar' '
176
- (cd relative-clone &&
177
- git remote set-url origin ./foo/bar &&
178
- git submodule sync &&
179
- (cd submodule &&
180
- #actual ./foo/submodule
181
- test "$(git config remote.origin.url)" = "../foo/submodule"
182
- )
216
+ (
217
+ cd relative-clone &&
218
+ git remote set-url origin ./foo/bar &&
219
+ git submodule sync &&
220
+ (
221
+ cd submodule &&
222
+ #actual ./foo/submodule
223
+ test "$(git config remote.origin.url)" = "../foo/submodule"
224
+ )
183
225
)
184
226
'
185
227
186
228
test_expect_success ' "git submodule sync" handles origin URL of the form ../foo' '
187
- (cd relative-clone &&
188
- git remote set-url origin ../foo &&
189
- git submodule sync &&
190
- (cd submodule &&
191
- #actual ../submodule
192
- test "$(git config remote.origin.url)" = "../../submodule"
193
- )
229
+ (
230
+ cd relative-clone &&
231
+ git remote set-url origin ../foo &&
232
+ git submodule sync &&
233
+ (
234
+ cd submodule &&
235
+ #actual ../submodule
236
+ test "$(git config remote.origin.url)" = "../../submodule"
237
+ )
194
238
)
195
239
'
196
240
197
241
test_expect_success ' "git submodule sync" handles origin URL of the form ../foo/bar' '
198
- (cd relative-clone &&
199
- git remote set-url origin ../foo/bar &&
200
- git submodule sync &&
201
- (cd submodule &&
202
- #actual ../foo/submodule
203
- test "$(git config remote.origin.url)" = "../../foo/submodule"
204
- )
242
+ (
243
+ cd relative-clone &&
244
+ git remote set-url origin ../foo/bar &&
245
+ git submodule sync &&
246
+ (
247
+ cd submodule &&
248
+ #actual ../foo/submodule
249
+ test "$(git config remote.origin.url)" = "../../foo/submodule"
250
+ )
205
251
)
206
252
'
207
253
208
254
test_expect_success ' "git submodule sync" handles origin URL of the form ../foo/bar with deeply nested submodule' '
209
- (cd relative-clone &&
210
- git remote set-url origin ../foo/bar &&
211
- mkdir -p a/b/c &&
212
- ( cd a/b/c &&
213
- git init &&
214
- :> .gitignore &&
215
- git add .gitignore &&
216
- test_tick &&
217
- git commit -m "initial commit" ) &&
218
- git submodule add ../bar/a/b/c ./a/b/c &&
219
- git submodule sync &&
220
- (cd a/b/c &&
221
- #actual ../foo/bar/a/b/c
222
- test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"
223
- )
255
+ (
256
+ cd relative-clone &&
257
+ git remote set-url origin ../foo/bar &&
258
+ mkdir -p a/b/c &&
259
+ (
260
+ cd a/b/c &&
261
+ git init &&
262
+ >.gitignore &&
263
+ git add .gitignore &&
264
+ test_tick &&
265
+ git commit -m "initial commit"
266
+ ) &&
267
+ git submodule add ../bar/a/b/c ./a/b/c &&
268
+ git submodule sync &&
269
+ (
270
+ cd a/b/c &&
271
+ #actual ../foo/bar/a/b/c
272
+ test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"
273
+ )
224
274
)
225
275
'
226
276
0 commit comments