]>
Commit | Line | Data |
---|---|---|
42639d23 JL |
1 | # Create a submodule layout used for all tests below. |
2 | # | |
3 | # The following use cases are covered: | |
4 | # - New submodule (no_submodule => add_sub1) | |
5 | # - Removed submodule (add_sub1 => remove_sub1) | |
6 | # - Updated submodule (add_sub1 => modify_sub1) | |
259f3ee2 | 7 | # - Updated submodule recursively (add_nested_sub => modify_sub1_recursively) |
42639d23 JL |
8 | # - Submodule updated to invalid commit (add_sub1 => invalid_sub1) |
9 | # - Submodule updated from invalid commit (invalid_sub1 => valid_sub1) | |
10 | # - Submodule replaced by tracked files in directory (add_sub1 => | |
11 | # replace_sub1_with_directory) | |
12 | # - Directory containing tracked files replaced by submodule | |
13 | # (replace_sub1_with_directory => replace_directory_with_sub1) | |
14 | # - Submodule replaced by tracked file with the same name (add_sub1 => | |
15 | # replace_sub1_with_file) | |
16 | # - Tracked file replaced by submodule (replace_sub1_with_file => | |
17 | # replace_file_with_sub1) | |
18 | # | |
eb41e7fe SB |
19 | # ----O |
20 | # / ^ | |
21 | # / remove_sub1 | |
22 | # / | |
259f3ee2 SB |
23 | # add_sub1 /-------O---------O--------O modify_sub1_recursively |
24 | # | / ^ add_nested_sub | |
eb41e7fe SB |
25 | # | / modify_sub1 |
26 | # v/ | |
27 | # O------O-----------O---------O | |
28 | # ^ \ ^ replace_directory_with_sub1 | |
29 | # | \ replace_sub1_with_directory | |
30 | # no_submodule \ | |
31 | # --------O---------O | |
32 | # \ ^ replace_file_with_sub1 | |
33 | # \ replace_sub1_with_file | |
34 | # \ | |
35 | # ----O---------O | |
36 | # ^ valid_sub1 | |
37 | # invalid_sub1 | |
42639d23 | 38 | # |
eb41e7fe | 39 | |
42639d23 | 40 | create_lib_submodule_repo () { |
a70ef2da SB |
41 | git init submodule_update_sub1 && |
42 | ( | |
43 | cd submodule_update_sub1 && | |
44 | echo "expect" >>.gitignore && | |
45 | echo "actual" >>.gitignore && | |
46 | echo "x" >file1 && | |
47 | echo "y" >file2 && | |
48 | git add .gitignore file1 file2 && | |
49 | git commit -m "Base inside first submodule" && | |
50 | git branch "no_submodule" | |
51 | ) && | |
259f3ee2 SB |
52 | git init submodule_update_sub2 && |
53 | ( | |
54 | cd submodule_update_sub2 | |
55 | echo "expect" >>.gitignore && | |
56 | echo "actual" >>.gitignore && | |
57 | echo "x" >file1 && | |
58 | echo "y" >file2 && | |
59 | git add .gitignore file1 file2 && | |
60 | git commit -m "nested submodule base" && | |
61 | git branch "no_submodule" | |
62 | ) && | |
42639d23 JL |
63 | git init submodule_update_repo && |
64 | ( | |
65 | cd submodule_update_repo && | |
66 | echo "expect" >>.gitignore && | |
67 | echo "actual" >>.gitignore && | |
68 | echo "x" >file1 && | |
69 | echo "y" >file2 && | |
70 | git add .gitignore file1 file2 && | |
71 | git commit -m "Base" && | |
72 | git branch "no_submodule" && | |
73 | ||
74 | git checkout -b "add_sub1" && | |
a70ef2da | 75 | git submodule add ../submodule_update_sub1 sub1 && |
823bab09 | 76 | git submodule add ../submodule_update_sub1 uninitialized_sub && |
42639d23 JL |
77 | git config -f .gitmodules submodule.sub1.ignore all && |
78 | git config submodule.sub1.ignore all && | |
79 | git add .gitmodules && | |
80 | git commit -m "Add sub1" && | |
eb41e7fe SB |
81 | |
82 | git checkout -b remove_sub1 add_sub1 && | |
42639d23 JL |
83 | git revert HEAD && |
84 | ||
eb41e7fe | 85 | git checkout -b modify_sub1 add_sub1 && |
42639d23 JL |
86 | git submodule update && |
87 | ( | |
88 | cd sub1 && | |
89 | git fetch && | |
90 | git checkout -b "modifications" && | |
91 | echo "z" >file2 && | |
92 | echo "x" >file3 && | |
93 | git add file2 file3 && | |
94 | git commit -m "modified file2 and added file3" && | |
95 | git push origin modifications | |
96 | ) && | |
97 | git add sub1 && | |
98 | git commit -m "Modify sub1" && | |
99 | ||
259f3ee2 SB |
100 | git checkout -b add_nested_sub modify_sub1 && |
101 | git -C sub1 checkout -b "add_nested_sub" && | |
102 | git -C sub1 submodule add --branch no_submodule ../submodule_update_sub2 sub2 && | |
103 | git -C sub1 commit -a -m "add a nested submodule" && | |
104 | git add sub1 && | |
105 | git commit -a -m "update submodule, that updates a nested submodule" && | |
106 | git checkout -b modify_sub1_recursively && | |
107 | git -C sub1 checkout -b modify_sub1_recursively && | |
108 | git -C sub1/sub2 checkout -b modify_sub1_recursively && | |
109 | echo change >sub1/sub2/file3 && | |
110 | git -C sub1/sub2 add file3 && | |
111 | git -C sub1/sub2 commit -m "make a change in nested sub" && | |
112 | git -C sub1 add sub2 && | |
113 | git -C sub1 commit -m "update nested sub" && | |
114 | git add sub1 && | |
115 | git commit -m "update sub1, that updates nested sub" && | |
116 | git -C sub1 push origin modify_sub1_recursively && | |
117 | git -C sub1/sub2 push origin modify_sub1_recursively && | |
118 | git -C sub1 submodule deinit -f --all && | |
119 | ||
eb41e7fe | 120 | git checkout -b replace_sub1_with_directory add_sub1 && |
42639d23 | 121 | git submodule update && |
3290fe6d | 122 | git -C sub1 checkout modifications && |
42639d23 JL |
123 | git rm --cached sub1 && |
124 | rm sub1/.git* && | |
125 | git config -f .gitmodules --remove-section "submodule.sub1" && | |
126 | git add .gitmodules sub1/* && | |
127 | git commit -m "Replace sub1 with directory" && | |
eb41e7fe | 128 | |
42639d23 JL |
129 | git checkout -b replace_directory_with_sub1 && |
130 | git revert HEAD && | |
131 | ||
eb41e7fe | 132 | git checkout -b replace_sub1_with_file add_sub1 && |
42639d23 JL |
133 | git rm sub1 && |
134 | echo "content" >sub1 && | |
135 | git add sub1 && | |
136 | git commit -m "Replace sub1 with file" && | |
eb41e7fe | 137 | |
42639d23 JL |
138 | git checkout -b replace_file_with_sub1 && |
139 | git revert HEAD && | |
140 | ||
eb41e7fe | 141 | git checkout -b invalid_sub1 add_sub1 && |
76c23892 | 142 | git update-index --cacheinfo 160000 $(test_oid numeric) sub1 && |
42639d23 JL |
143 | git commit -m "Invalid sub1 commit" && |
144 | git checkout -b valid_sub1 && | |
145 | git revert HEAD && | |
eb41e7fe | 146 | |
42639d23 JL |
147 | git checkout master |
148 | ) | |
149 | } | |
150 | ||
151 | # Helper function to replace gitfile with .git directory | |
152 | replace_gitfile_with_git_dir () { | |
153 | ( | |
154 | cd "$1" && | |
155 | git_dir="$(git rev-parse --git-dir)" && | |
156 | rm -f .git && | |
157 | cp -R "$git_dir" .git && | |
158 | GIT_WORK_TREE=. git config --unset core.worktree | |
159 | ) | |
160 | } | |
161 | ||
162 | # Test that the .git directory in the submodule is unchanged (except for the | |
163 | # core.worktree setting, which appears only in $GIT_DIR/modules/$1/config). | |
164 | # Call this function before test_submodule_content as the latter might | |
165 | # write the index file leading to false positive index differences. | |
166 | # | |
167 | # Note that this only supports submodules at the root level of the | |
168 | # superproject, with the default name, i.e. same as its path. | |
169 | test_git_directory_is_unchanged () { | |
170 | ( | |
171 | cd ".git/modules/$1" && | |
172 | # does core.worktree point at the right place? | |
173 | test "$(git config core.worktree)" = "../../../$1" && | |
174 | # remove it temporarily before comparing, as | |
175 | # "$1/.git/config" lacks it... | |
176 | git config --unset core.worktree | |
177 | ) && | |
178 | diff -r ".git/modules/$1" "$1/.git" && | |
179 | ( | |
180 | # ... and then restore. | |
181 | cd ".git/modules/$1" && | |
182 | git config core.worktree "../../../$1" | |
183 | ) | |
184 | } | |
185 | ||
259f3ee2 SB |
186 | test_git_directory_exists() { |
187 | test -e ".git/modules/$1" && | |
188 | if test -f sub1/.git | |
189 | then | |
190 | # does core.worktree point at the right place? | |
191 | test "$(git -C .git/modules/$1 config core.worktree)" = "../../../$1" | |
192 | fi | |
193 | } | |
194 | ||
42639d23 JL |
195 | # Helper function to be executed at the start of every test below, it sets up |
196 | # the submodule repo if it doesn't exist and configures the most problematic | |
197 | # settings for diff.ignoreSubmodules. | |
198 | prolog () { | |
76c23892 | 199 | test_oid_init && |
42639d23 JL |
200 | (test -d submodule_update_repo || create_lib_submodule_repo) && |
201 | test_config_global diff.ignoreSubmodules all && | |
202 | test_config diff.ignoreSubmodules all | |
203 | } | |
204 | ||
205 | # Helper function to bring work tree back into the state given by the | |
206 | # commit. This includes trying to populate sub1 accordingly if it exists and | |
207 | # should be updated to an existing commit. | |
208 | reset_work_tree_to () { | |
209 | rm -rf submodule_update && | |
210 | git clone submodule_update_repo submodule_update && | |
211 | ( | |
212 | cd submodule_update && | |
213 | rm -rf sub1 && | |
214 | git checkout -f "$1" && | |
215 | git status -u -s >actual && | |
216 | test_must_be_empty actual && | |
03c7e2a3 SB |
217 | hash=$(git rev-parse --revs-only HEAD:sub1) && |
218 | if test -n "$hash" && | |
219 | test $(cd "../submodule_update_sub1" && git rev-parse --verify "$hash^{commit}") | |
42639d23 JL |
220 | then |
221 | git submodule update --init --recursive "sub1" | |
222 | fi | |
223 | ) | |
224 | } | |
225 | ||
259f3ee2 SB |
226 | reset_work_tree_to_interested () { |
227 | reset_work_tree_to $1 && | |
228 | # make the submodule git dirs available | |
229 | if ! test -d submodule_update/.git/modules/sub1 | |
230 | then | |
231 | mkdir -p submodule_update/.git/modules && | |
232 | cp -r submodule_update_repo/.git/modules/sub1 submodule_update/.git/modules/sub1 | |
233 | GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1 config --unset core.worktree | |
234 | fi && | |
235 | if ! test -d submodule_update/.git/modules/sub1/modules/sub2 | |
236 | then | |
237 | mkdir -p submodule_update/.git/modules/sub1/modules && | |
238 | cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2 | |
8eda5efa | 239 | # core.worktree is unset for sub2 as it is not checked out |
259f3ee2 SB |
240 | fi && |
241 | # indicate we are interested in the submodule: | |
242 | git -C submodule_update config submodule.sub1.url "bogus" && | |
243 | # sub1 might not be checked out, so use the git dir | |
244 | git -C submodule_update/.git/modules/sub1 config submodule.sub2.url "bogus" | |
245 | } | |
246 | ||
42639d23 JL |
247 | # Test that the superproject contains the content according to commit "$1" |
248 | # (the work tree must match the index for everything but submodules but the | |
249 | # index must exactly match the given commit including any submodule SHA-1s). | |
250 | test_superproject_content () { | |
251 | git diff-index --cached "$1" >actual && | |
252 | test_must_be_empty actual && | |
253 | git diff-files --ignore-submodules >actual && | |
254 | test_must_be_empty actual | |
255 | } | |
256 | ||
257 | # Test that the given submodule at path "$1" contains the content according | |
258 | # to the submodule commit recorded in the superproject's commit "$2" | |
259 | test_submodule_content () { | |
2f70edcc SB |
260 | if test x"$1" = "x-C" |
261 | then | |
262 | cd "$2" | |
263 | shift; shift; | |
264 | fi | |
42639d23 JL |
265 | if test $# != 2 |
266 | then | |
267 | echo "test_submodule_content needs two arguments" | |
268 | return 1 | |
269 | fi && | |
270 | submodule="$1" && | |
271 | commit="$2" && | |
272 | test -d "$submodule"/ && | |
273 | if ! test -f "$submodule"/.git && ! test -d "$submodule"/.git | |
274 | then | |
275 | echo "Submodule $submodule is not populated" | |
276 | return 1 | |
277 | fi && | |
278 | sha1=$(git rev-parse --verify "$commit:$submodule") && | |
279 | if test -z "$sha1" | |
280 | then | |
281 | echo "Couldn't retrieve SHA-1 of $submodule for $commit" | |
282 | return 1 | |
283 | fi && | |
284 | ( | |
285 | cd "$submodule" && | |
286 | git status -u -s >actual && | |
287 | test_must_be_empty actual && | |
288 | git diff "$sha1" >actual && | |
289 | test_must_be_empty actual | |
290 | ) | |
291 | } | |
292 | ||
293 | # Test that the following transitions are correctly handled: | |
294 | # - Updated submodule | |
295 | # - New submodule | |
296 | # - Removed submodule | |
297 | # - Directory containing tracked files replaced by submodule | |
298 | # - Submodule replaced by tracked files in directory | |
299 | # - Submodule replaced by tracked file with the same name | |
300 | # - tracked file replaced by submodule | |
301 | # | |
302 | # The default is that submodule contents aren't changed until "git submodule | |
303 | # update" is run. And even then that command doesn't delete the work tree of | |
304 | # a removed submodule. | |
305 | # | |
306 | # Removing a submodule containing a .git directory must fail even when forced | |
307 | # to protect the history! | |
308 | # | |
309 | ||
d3b5a497 JT |
310 | # Internal function; use test_submodule_switch() or |
311 | # test_submodule_forced_switch() instead. | |
312 | test_submodule_switch_common() { | |
42639d23 JL |
313 | command="$1" |
314 | ######################### Appearing submodule ######################### | |
315 | # Switching to a commit letting a submodule appear creates empty dir ... | |
da7fe3fb JL |
316 | if test "$KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES" = 1 |
317 | then | |
318 | # Restoring stash fails to restore submodule index entry | |
319 | RESULT="failure" | |
320 | else | |
321 | RESULT="success" | |
322 | fi | |
323 | test_expect_$RESULT "$command: added submodule creates empty directory" ' | |
42639d23 JL |
324 | prolog && |
325 | reset_work_tree_to no_submodule && | |
326 | ( | |
327 | cd submodule_update && | |
328 | git branch -t add_sub1 origin/add_sub1 && | |
329 | $command add_sub1 && | |
330 | test_superproject_content origin/add_sub1 && | |
331 | test_dir_is_empty sub1 && | |
332 | git submodule update --init --recursive && | |
333 | test_submodule_content sub1 origin/add_sub1 | |
334 | ) | |
335 | ' | |
d3b5a497 | 336 | # ... and doesn't care if it already exists. |
da7fe3fb | 337 | test_expect_$RESULT "$command: added submodule leaves existing empty directory alone" ' |
42639d23 JL |
338 | prolog && |
339 | reset_work_tree_to no_submodule && | |
340 | ( | |
341 | cd submodule_update && | |
342 | mkdir sub1 && | |
343 | git branch -t add_sub1 origin/add_sub1 && | |
344 | $command add_sub1 && | |
345 | test_superproject_content origin/add_sub1 && | |
346 | test_dir_is_empty sub1 && | |
347 | git submodule update --init --recursive && | |
348 | test_submodule_content sub1 origin/add_sub1 | |
349 | ) | |
350 | ' | |
42639d23 JL |
351 | # Replacing a tracked file with a submodule produces an empty |
352 | # directory ... | |
da7fe3fb | 353 | test_expect_$RESULT "$command: replace tracked file with submodule creates empty directory" ' |
42639d23 JL |
354 | prolog && |
355 | reset_work_tree_to replace_sub1_with_file && | |
356 | ( | |
357 | cd submodule_update && | |
358 | git branch -t replace_file_with_sub1 origin/replace_file_with_sub1 && | |
359 | $command replace_file_with_sub1 && | |
360 | test_superproject_content origin/replace_file_with_sub1 && | |
361 | test_dir_is_empty sub1 && | |
362 | git submodule update --init --recursive && | |
363 | test_submodule_content sub1 origin/replace_file_with_sub1 | |
364 | ) | |
365 | ' | |
366 | # ... as does removing a directory with tracked files with a | |
367 | # submodule. | |
663ed39a JL |
368 | if test "$KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR" = 1 |
369 | then | |
370 | # Non fast-forward merges fail with "Directory sub1 doesn't | |
371 | # exist. sub1" because the empty submodule directory is not | |
372 | # created | |
373 | RESULT="failure" | |
374 | else | |
375 | RESULT="success" | |
376 | fi | |
377 | test_expect_$RESULT "$command: replace directory with submodule" ' | |
42639d23 JL |
378 | prolog && |
379 | reset_work_tree_to replace_sub1_with_directory && | |
380 | ( | |
381 | cd submodule_update && | |
382 | git branch -t replace_directory_with_sub1 origin/replace_directory_with_sub1 && | |
383 | $command replace_directory_with_sub1 && | |
384 | test_superproject_content origin/replace_directory_with_sub1 && | |
385 | test_dir_is_empty sub1 && | |
386 | git submodule update --init --recursive && | |
387 | test_submodule_content sub1 origin/replace_directory_with_sub1 | |
388 | ) | |
389 | ' | |
390 | ||
391 | ######################## Disappearing submodule ####################### | |
392 | # Removing a submodule doesn't remove its work tree ... | |
da7fe3fb JL |
393 | if test "$KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES" = 1 |
394 | then | |
395 | RESULT="failure" | |
396 | else | |
397 | RESULT="success" | |
398 | fi | |
399 | test_expect_$RESULT "$command: removed submodule leaves submodule directory and its contents in place" ' | |
42639d23 JL |
400 | prolog && |
401 | reset_work_tree_to add_sub1 && | |
402 | ( | |
403 | cd submodule_update && | |
404 | git branch -t remove_sub1 origin/remove_sub1 && | |
405 | $command remove_sub1 && | |
406 | test_superproject_content origin/remove_sub1 && | |
407 | test_submodule_content sub1 origin/add_sub1 | |
408 | ) | |
409 | ' | |
410 | # ... especially when it contains a .git directory. | |
da7fe3fb | 411 | test_expect_$RESULT "$command: removed submodule leaves submodule containing a .git directory alone" ' |
42639d23 JL |
412 | prolog && |
413 | reset_work_tree_to add_sub1 && | |
414 | ( | |
415 | cd submodule_update && | |
416 | git branch -t remove_sub1 origin/remove_sub1 && | |
417 | replace_gitfile_with_git_dir sub1 && | |
418 | $command remove_sub1 && | |
419 | test_superproject_content origin/remove_sub1 && | |
420 | test_git_directory_is_unchanged sub1 && | |
421 | test_submodule_content sub1 origin/add_sub1 | |
422 | ) | |
423 | ' | |
424 | # Replacing a submodule with files in a directory must fail as the | |
425 | # submodule work tree isn't removed ... | |
663ed39a JL |
426 | if test "$KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES" = 1 |
427 | then | |
428 | # Non fast-forward merges attempt to merge the former | |
429 | # submodule files with the newly checked out ones in the | |
430 | # directory of the same name while it shouldn't. | |
431 | RESULT="failure" | |
d3b5a497 JT |
432 | elif test "$KNOWN_FAILURE_FORCED_SWITCH_TESTS" = 1 |
433 | then | |
434 | # All existing tests that use test_submodule_forced_switch() | |
435 | # require this. | |
436 | RESULT="failure" | |
663ed39a JL |
437 | else |
438 | RESULT="success" | |
439 | fi | |
440 | test_expect_$RESULT "$command: replace submodule with a directory must fail" ' | |
42639d23 JL |
441 | prolog && |
442 | reset_work_tree_to add_sub1 && | |
443 | ( | |
444 | cd submodule_update && | |
445 | git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && | |
446 | test_must_fail $command replace_sub1_with_directory && | |
447 | test_superproject_content origin/add_sub1 && | |
448 | test_submodule_content sub1 origin/add_sub1 | |
449 | ) | |
450 | ' | |
451 | # ... especially when it contains a .git directory. | |
663ed39a | 452 | test_expect_$RESULT "$command: replace submodule containing a .git directory with a directory must fail" ' |
42639d23 JL |
453 | prolog && |
454 | reset_work_tree_to add_sub1 && | |
455 | ( | |
456 | cd submodule_update && | |
457 | git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && | |
458 | replace_gitfile_with_git_dir sub1 && | |
459 | test_must_fail $command replace_sub1_with_directory && | |
460 | test_superproject_content origin/add_sub1 && | |
461 | test_git_directory_is_unchanged sub1 && | |
462 | test_submodule_content sub1 origin/add_sub1 | |
463 | ) | |
464 | ' | |
465 | # Replacing it with a file must fail as it could throw away any local | |
466 | # work tree changes ... | |
467 | test_expect_failure "$command: replace submodule with a file must fail" ' | |
468 | prolog && | |
469 | reset_work_tree_to add_sub1 && | |
470 | ( | |
471 | cd submodule_update && | |
472 | git branch -t replace_sub1_with_file origin/replace_sub1_with_file && | |
473 | test_must_fail $command replace_sub1_with_file && | |
474 | test_superproject_content origin/add_sub1 && | |
475 | test_submodule_content sub1 origin/add_sub1 | |
476 | ) | |
477 | ' | |
478 | # ... or even destroy unpushed parts of submodule history if that | |
479 | # still uses a .git directory. | |
480 | test_expect_failure "$command: replace submodule containing a .git directory with a file must fail" ' | |
481 | prolog && | |
482 | reset_work_tree_to add_sub1 && | |
483 | ( | |
484 | cd submodule_update && | |
485 | git branch -t replace_sub1_with_file origin/replace_sub1_with_file && | |
486 | replace_gitfile_with_git_dir sub1 && | |
487 | test_must_fail $command replace_sub1_with_file && | |
488 | test_superproject_content origin/add_sub1 && | |
489 | test_git_directory_is_unchanged sub1 && | |
490 | test_submodule_content sub1 origin/add_sub1 | |
491 | ) | |
492 | ' | |
493 | ||
494 | ########################## Modified submodule ######################### | |
495 | # Updating a submodule sha1 doesn't update the submodule's work tree | |
283f56a4 JL |
496 | if test "$KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT" = 1 |
497 | then | |
498 | # When cherry picking a SHA-1 update for an ignored submodule | |
499 | # the commit incorrectly fails with "The previous cherry-pick | |
500 | # is now empty, possibly due to conflict resolution." | |
501 | RESULT="failure" | |
502 | else | |
503 | RESULT="success" | |
504 | fi | |
505 | test_expect_$RESULT "$command: modified submodule does not update submodule work tree" ' | |
42639d23 JL |
506 | prolog && |
507 | reset_work_tree_to add_sub1 && | |
508 | ( | |
509 | cd submodule_update && | |
510 | git branch -t modify_sub1 origin/modify_sub1 && | |
511 | $command modify_sub1 && | |
512 | test_superproject_content origin/modify_sub1 && | |
513 | test_submodule_content sub1 origin/add_sub1 && | |
514 | git submodule update && | |
515 | test_submodule_content sub1 origin/modify_sub1 | |
516 | ) | |
517 | ' | |
42639d23 JL |
518 | # Updating a submodule to an invalid sha1 doesn't update the |
519 | # submodule's work tree, subsequent update will fail | |
283f56a4 | 520 | test_expect_$RESULT "$command: modified submodule does not update submodule work tree to invalid commit" ' |
42639d23 JL |
521 | prolog && |
522 | reset_work_tree_to add_sub1 && | |
523 | ( | |
524 | cd submodule_update && | |
525 | git branch -t invalid_sub1 origin/invalid_sub1 && | |
526 | $command invalid_sub1 && | |
527 | test_superproject_content origin/invalid_sub1 && | |
528 | test_submodule_content sub1 origin/add_sub1 && | |
529 | test_must_fail git submodule update && | |
530 | test_submodule_content sub1 origin/add_sub1 | |
531 | ) | |
532 | ' | |
533 | # Updating a submodule from an invalid sha1 doesn't update the | |
534 | # submodule's work tree, subsequent update will succeed | |
283f56a4 | 535 | test_expect_$RESULT "$command: modified submodule does not update submodule work tree from invalid commit" ' |
42639d23 JL |
536 | prolog && |
537 | reset_work_tree_to invalid_sub1 && | |
538 | ( | |
539 | cd submodule_update && | |
540 | git branch -t valid_sub1 origin/valid_sub1 && | |
541 | $command valid_sub1 && | |
542 | test_superproject_content origin/valid_sub1 && | |
543 | test_dir_is_empty sub1 && | |
544 | git submodule update --init --recursive && | |
545 | test_submodule_content sub1 origin/valid_sub1 | |
546 | ) | |
547 | ' | |
548 | } | |
549 | ||
d3b5a497 JT |
550 | # Declares and invokes several tests that, in various situations, checks that |
551 | # the provided transition function: | |
552 | # - succeeds in updating the worktree and index of a superproject to a target | |
553 | # commit, or fails atomically (depending on the test situation) | |
554 | # - if succeeds, the contents of submodule directories are unchanged | |
555 | # - if succeeds, once "git submodule update" is invoked, the contents of | |
556 | # submodule directories are updated | |
557 | # | |
a0500447 JT |
558 | # If the command under test is known to not work with submodules in certain |
559 | # conditions, set the appropriate KNOWN_FAILURE_* variable used in the tests | |
560 | # below to 1. | |
561 | # | |
d3b5a497 JT |
562 | # Use as follows: |
563 | # | |
564 | # my_func () { | |
565 | # target=$1 | |
566 | # # Do something here that updates the worktree and index to match target, | |
567 | # # but not any submodule directories. | |
568 | # } | |
569 | # test_submodule_switch "my_func" | |
570 | test_submodule_switch () { | |
42639d23 | 571 | command="$1" |
d3b5a497 JT |
572 | test_submodule_switch_common "$command" |
573 | ||
574 | # An empty directory does not prevent the creation of a submodule of | |
575 | # the same name, but a file does. | |
576 | test_expect_success "$command: added submodule doesn't remove untracked unignored file with same name" ' | |
42639d23 JL |
577 | prolog && |
578 | reset_work_tree_to no_submodule && | |
579 | ( | |
580 | cd submodule_update && | |
581 | git branch -t add_sub1 origin/add_sub1 && | |
d3b5a497 JT |
582 | >sub1 && |
583 | test_must_fail $command add_sub1 && | |
584 | test_superproject_content origin/no_submodule && | |
585 | test_must_be_empty sub1 | |
42639d23 JL |
586 | ) |
587 | ' | |
d3b5a497 JT |
588 | } |
589 | ||
590 | # Same as test_submodule_switch(), except that throwing away local changes in | |
591 | # the superproject is allowed. | |
592 | test_submodule_forced_switch () { | |
593 | command="$1" | |
594 | KNOWN_FAILURE_FORCED_SWITCH_TESTS=1 | |
595 | test_submodule_switch_common "$command" | |
596 | ||
597 | # When forced, a file in the superproject does not prevent creating a | |
598 | # submodule of the same name. | |
42639d23 JL |
599 | test_expect_success "$command: added submodule does remove untracked unignored file with same name when forced" ' |
600 | prolog && | |
601 | reset_work_tree_to no_submodule && | |
602 | ( | |
603 | cd submodule_update && | |
604 | git branch -t add_sub1 origin/add_sub1 && | |
605 | >sub1 && | |
606 | $command add_sub1 && | |
607 | test_superproject_content origin/add_sub1 && | |
608 | test_dir_is_empty sub1 | |
609 | ) | |
610 | ' | |
42639d23 | 611 | } |
259f3ee2 SB |
612 | |
613 | # Test that submodule contents are correctly updated when switching | |
614 | # between commits that change a submodule. | |
615 | # Test that the following transitions are correctly handled: | |
616 | # (These tests are also above in the case where we expect no change | |
617 | # in the submodule) | |
618 | # - Updated submodule | |
619 | # - New submodule | |
620 | # - Removed submodule | |
621 | # - Directory containing tracked files replaced by submodule | |
622 | # - Submodule replaced by tracked files in directory | |
623 | # - Submodule replaced by tracked file with the same name | |
624 | # - tracked file replaced by submodule | |
625 | # | |
626 | # New test cases | |
627 | # - Removing a submodule with a git directory absorbs the submodules | |
628 | # git directory first into the superproject. | |
629 | ||
a0500447 JT |
630 | # Internal function; use test_submodule_switch_recursing_with_args() or |
631 | # test_submodule_forced_switch_recursing_with_args() instead. | |
632 | test_submodule_recursing_with_args_common() { | |
633 | command="$1" | |
634 | ||
259f3ee2 SB |
635 | ######################### Appearing submodule ######################### |
636 | # Switching to a commit letting a submodule appear checks it out ... | |
637 | test_expect_success "$command: added submodule is checked out" ' | |
638 | prolog && | |
639 | reset_work_tree_to_interested no_submodule && | |
640 | ( | |
641 | cd submodule_update && | |
642 | git branch -t add_sub1 origin/add_sub1 && | |
643 | $command add_sub1 && | |
644 | test_superproject_content origin/add_sub1 && | |
645 | test_submodule_content sub1 origin/add_sub1 | |
646 | ) | |
647 | ' | |
a0500447 | 648 | # ... ignoring an empty existing directory. |
259f3ee2 SB |
649 | test_expect_success "$command: added submodule is checked out in empty dir" ' |
650 | prolog && | |
651 | reset_work_tree_to_interested no_submodule && | |
652 | ( | |
653 | cd submodule_update && | |
654 | mkdir sub1 && | |
655 | git branch -t add_sub1 origin/add_sub1 && | |
656 | $command add_sub1 && | |
657 | test_superproject_content origin/add_sub1 && | |
658 | test_submodule_content sub1 origin/add_sub1 | |
659 | ) | |
660 | ' | |
3ef25380 SB |
661 | test_expect_success "$command: submodule branch is not changed, detach HEAD instead" ' |
662 | prolog && | |
663 | reset_work_tree_to_interested add_sub1 && | |
664 | ( | |
665 | cd submodule_update && | |
666 | git -C sub1 checkout -b keep_branch && | |
667 | git -C sub1 rev-parse HEAD >expect && | |
6419a123 SB |
668 | git branch -t modify_sub1 origin/modify_sub1 && |
669 | $command modify_sub1 && | |
3ef25380 SB |
670 | test_superproject_content origin/modify_sub1 && |
671 | test_submodule_content sub1 origin/modify_sub1 && | |
672 | git -C sub1 rev-parse keep_branch >actual && | |
673 | test_cmp expect actual && | |
674 | test_must_fail git -C sub1 symbolic-ref HEAD | |
675 | ) | |
676 | ' | |
677 | ||
259f3ee2 SB |
678 | # Replacing a tracked file with a submodule produces a checked out submodule |
679 | test_expect_success "$command: replace tracked file with submodule checks out submodule" ' | |
680 | prolog && | |
681 | reset_work_tree_to_interested replace_sub1_with_file && | |
682 | ( | |
683 | cd submodule_update && | |
684 | git branch -t replace_file_with_sub1 origin/replace_file_with_sub1 && | |
685 | $command replace_file_with_sub1 && | |
686 | test_superproject_content origin/replace_file_with_sub1 && | |
687 | test_submodule_content sub1 origin/replace_file_with_sub1 | |
688 | ) | |
689 | ' | |
690 | # ... as does removing a directory with tracked files with a submodule. | |
691 | test_expect_success "$command: replace directory with submodule" ' | |
692 | prolog && | |
693 | reset_work_tree_to_interested replace_sub1_with_directory && | |
694 | ( | |
695 | cd submodule_update && | |
696 | git branch -t replace_directory_with_sub1 origin/replace_directory_with_sub1 && | |
697 | $command replace_directory_with_sub1 && | |
698 | test_superproject_content origin/replace_directory_with_sub1 && | |
699 | test_submodule_content sub1 origin/replace_directory_with_sub1 | |
700 | ) | |
701 | ' | |
702 | ||
703 | ######################## Disappearing submodule ####################### | |
704 | # Removing a submodule removes its work tree ... | |
705 | test_expect_success "$command: removed submodule removes submodules working tree" ' | |
706 | prolog && | |
707 | reset_work_tree_to_interested add_sub1 && | |
708 | ( | |
709 | cd submodule_update && | |
710 | git branch -t remove_sub1 origin/remove_sub1 && | |
711 | $command remove_sub1 && | |
712 | test_superproject_content origin/remove_sub1 && | |
898c2e65 SB |
713 | ! test -e sub1 && |
714 | test_must_fail git config -f .git/modules/sub1/config core.worktree | |
259f3ee2 SB |
715 | ) |
716 | ' | |
717 | # ... absorbing a .git directory along the way. | |
718 | test_expect_success "$command: removed submodule absorbs submodules .git directory" ' | |
719 | prolog && | |
720 | reset_work_tree_to_interested add_sub1 && | |
721 | ( | |
722 | cd submodule_update && | |
723 | git branch -t remove_sub1 origin/remove_sub1 && | |
724 | replace_gitfile_with_git_dir sub1 && | |
725 | rm -rf .git/modules && | |
726 | $command remove_sub1 && | |
727 | test_superproject_content origin/remove_sub1 && | |
728 | ! test -e sub1 && | |
729 | test_git_directory_exists sub1 | |
730 | ) | |
731 | ' | |
259f3ee2 SB |
732 | |
733 | # Replacing it with a file ... | |
734 | test_expect_success "$command: replace submodule with a file" ' | |
735 | prolog && | |
736 | reset_work_tree_to_interested add_sub1 && | |
737 | ( | |
738 | cd submodule_update && | |
739 | git branch -t replace_sub1_with_file origin/replace_sub1_with_file && | |
740 | $command replace_sub1_with_file && | |
741 | test_superproject_content origin/replace_sub1_with_file && | |
742 | test -f sub1 | |
743 | ) | |
744 | ' | |
a0500447 JT |
745 | RESULTDS=success |
746 | if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1 | |
747 | then | |
748 | RESULTDS=failure | |
749 | fi | |
259f3ee2 | 750 | # ... must check its local work tree for untracked files |
1fc458d9 | 751 | test_expect_$RESULTDS "$command: replace submodule with a file must fail with untracked files" ' |
259f3ee2 SB |
752 | prolog && |
753 | reset_work_tree_to_interested add_sub1 && | |
754 | ( | |
755 | cd submodule_update && | |
756 | git branch -t replace_sub1_with_file origin/replace_sub1_with_file && | |
757 | : >sub1/untrackedfile && | |
758 | test_must_fail $command replace_sub1_with_file && | |
759 | test_superproject_content origin/add_sub1 && | |
e5d7e9f5 | 760 | test_submodule_content sub1 origin/add_sub1 && |
a0500447 | 761 | test -f sub1/untracked_file |
259f3ee2 SB |
762 | ) |
763 | ' | |
764 | ||
765 | ########################## Modified submodule ######################### | |
766 | # Updating a submodule sha1 updates the submodule's work tree | |
767 | test_expect_success "$command: modified submodule updates submodule work tree" ' | |
768 | prolog && | |
769 | reset_work_tree_to_interested add_sub1 && | |
770 | ( | |
771 | cd submodule_update && | |
772 | git branch -t modify_sub1 origin/modify_sub1 && | |
773 | $command modify_sub1 && | |
774 | test_superproject_content origin/modify_sub1 && | |
775 | test_submodule_content sub1 origin/modify_sub1 | |
776 | ) | |
777 | ' | |
259f3ee2 SB |
778 | # Updating a submodule to an invalid sha1 doesn't update the |
779 | # superproject nor the submodule's work tree. | |
780 | test_expect_success "$command: updating to a missing submodule commit fails" ' | |
781 | prolog && | |
782 | reset_work_tree_to_interested add_sub1 && | |
783 | ( | |
784 | cd submodule_update && | |
785 | git branch -t invalid_sub1 origin/invalid_sub1 && | |
ba95d4e4 SB |
786 | test_must_fail $command invalid_sub1 2>err && |
787 | test_i18ngrep sub1 err && | |
259f3ee2 SB |
788 | test_superproject_content origin/add_sub1 && |
789 | test_submodule_content sub1 origin/add_sub1 | |
790 | ) | |
791 | ' | |
259f3ee2 SB |
792 | } |
793 | ||
a0500447 JT |
794 | # Declares and invokes several tests that, in various situations, checks that |
795 | # the provided Git command, when invoked with --recurse-submodules: | |
796 | # - succeeds in updating the worktree and index of a superproject to a target | |
797 | # commit, or fails atomically (depending on the test situation) | |
798 | # - if succeeds, the contents of submodule directories are updated | |
799 | # | |
800 | # Specify the Git command so that "git $GIT_COMMAND --recurse-submodules" | |
801 | # works. | |
802 | # | |
803 | # If the command under test is known to not work with submodules in certain | |
804 | # conditions, set the appropriate KNOWN_FAILURE_* variable used in the tests | |
805 | # below to 1. | |
806 | # | |
807 | # Use as follows: | |
808 | # | |
809 | # test_submodule_switch_recursing_with_args "$GIT_COMMAND" | |
810 | test_submodule_switch_recursing_with_args () { | |
17f38cb7 SB |
811 | cmd_args="$1" |
812 | command="git $cmd_args --recurse-submodules" | |
a0500447 JT |
813 | test_submodule_recursing_with_args_common "$command" |
814 | ||
815 | RESULTDS=success | |
1fc458d9 SB |
816 | if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1 |
817 | then | |
a0500447 | 818 | RESULTDS=failure |
1fc458d9 | 819 | fi |
a0500447 JT |
820 | RESULTOI=success |
821 | if test "$KNOWN_FAILURE_SUBMODULE_OVERWRITE_IGNORED_UNTRACKED" = 1 | |
822 | then | |
823 | RESULTOI=failure | |
824 | fi | |
825 | # Switching to a commit letting a submodule appear cannot override an | |
826 | # untracked file. | |
827 | test_expect_success "$command: added submodule doesn't remove untracked file with same name" ' | |
259f3ee2 SB |
828 | prolog && |
829 | reset_work_tree_to_interested no_submodule && | |
830 | ( | |
831 | cd submodule_update && | |
832 | git branch -t add_sub1 origin/add_sub1 && | |
a0500447 JT |
833 | : >sub1 && |
834 | test_must_fail $command add_sub1 && | |
835 | test_superproject_content origin/no_submodule && | |
836 | test_must_be_empty sub1 | |
259f3ee2 SB |
837 | ) |
838 | ' | |
a0500447 JT |
839 | # ... but an ignored file is fine. |
840 | test_expect_$RESULTOI "$command: added submodule removes an untracked ignored file" ' | |
841 | test_when_finished "rm submodule_update/.git/info/exclude" && | |
259f3ee2 SB |
842 | prolog && |
843 | reset_work_tree_to_interested no_submodule && | |
844 | ( | |
845 | cd submodule_update && | |
846 | git branch -t add_sub1 origin/add_sub1 && | |
a0500447 | 847 | : >sub1 && |
e5d7e9f5 | 848 | echo sub1 >.git/info/exclude && |
259f3ee2 SB |
849 | $command add_sub1 && |
850 | test_superproject_content origin/add_sub1 && | |
851 | test_submodule_content sub1 origin/add_sub1 | |
852 | ) | |
853 | ' | |
a0500447 JT |
854 | |
855 | # Replacing a submodule with files in a directory must succeeds | |
856 | # when the submodule is clean | |
857 | test_expect_$RESULTDS "$command: replace submodule with a directory" ' | |
259f3ee2 | 858 | prolog && |
a0500447 | 859 | reset_work_tree_to_interested add_sub1 && |
259f3ee2 SB |
860 | ( |
861 | cd submodule_update && | |
a0500447 JT |
862 | git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && |
863 | $command replace_sub1_with_directory && | |
864 | test_superproject_content origin/replace_sub1_with_directory && | |
865 | test_submodule_content sub1 origin/replace_sub1_with_directory | |
259f3ee2 SB |
866 | ) |
867 | ' | |
a0500447 JT |
868 | # ... absorbing a .git directory. |
869 | test_expect_$RESULTDS "$command: replace submodule containing a .git directory with a directory must absorb the git dir" ' | |
259f3ee2 | 870 | prolog && |
a0500447 | 871 | reset_work_tree_to_interested add_sub1 && |
259f3ee2 SB |
872 | ( |
873 | cd submodule_update && | |
a0500447 JT |
874 | git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && |
875 | replace_gitfile_with_git_dir sub1 && | |
876 | rm -rf .git/modules && | |
877 | $command replace_sub1_with_directory && | |
878 | test_superproject_content origin/replace_sub1_with_directory && | |
879 | test_git_directory_exists sub1 | |
259f3ee2 SB |
880 | ) |
881 | ' | |
a0500447 JT |
882 | |
883 | # ... and ignored files are ignored | |
884 | test_expect_success "$command: replace submodule with a file works ignores ignored files in submodule" ' | |
885 | test_when_finished "rm submodule_update/.git/modules/sub1/info/exclude" && | |
259f3ee2 | 886 | prolog && |
a0500447 | 887 | reset_work_tree_to_interested add_sub1 && |
259f3ee2 SB |
888 | ( |
889 | cd submodule_update && | |
a0500447 | 890 | git branch -t replace_sub1_with_file origin/replace_sub1_with_file && |
63d963a4 | 891 | echo ignored >.git/modules/sub1/info/exclude && |
a0500447 JT |
892 | : >sub1/ignored && |
893 | $command replace_sub1_with_file && | |
894 | test_superproject_content origin/replace_sub1_with_file && | |
895 | test -f sub1 | |
259f3ee2 SB |
896 | ) |
897 | ' | |
898 | ||
a0500447 | 899 | test_expect_success "git -c submodule.recurse=true $cmd_args: modified submodule updates submodule work tree" ' |
259f3ee2 SB |
900 | prolog && |
901 | reset_work_tree_to_interested add_sub1 && | |
902 | ( | |
903 | cd submodule_update && | |
a0500447 JT |
904 | git branch -t modify_sub1 origin/modify_sub1 && |
905 | git -c submodule.recurse=true $cmd_args modify_sub1 && | |
906 | test_superproject_content origin/modify_sub1 && | |
907 | test_submodule_content sub1 origin/modify_sub1 | |
259f3ee2 SB |
908 | ) |
909 | ' | |
a0500447 JT |
910 | |
911 | # recursing deeper than one level doesn't work yet. | |
912 | test_expect_success "$command: modified submodule updates submodule recursively" ' | |
259f3ee2 | 913 | prolog && |
a0500447 | 914 | reset_work_tree_to_interested add_nested_sub && |
259f3ee2 SB |
915 | ( |
916 | cd submodule_update && | |
a0500447 JT |
917 | git branch -t modify_sub1_recursively origin/modify_sub1_recursively && |
918 | $command modify_sub1_recursively && | |
919 | test_superproject_content origin/modify_sub1_recursively && | |
920 | test_submodule_content sub1 origin/modify_sub1_recursively && | |
921 | test_submodule_content -C sub1 sub2 origin/modify_sub1_recursively | |
922 | ) | |
923 | ' | |
924 | } | |
925 | ||
926 | # Same as test_submodule_switch_recursing_with_args(), except that throwing | |
927 | # away local changes in the superproject is allowed. | |
928 | test_submodule_forced_switch_recursing_with_args () { | |
929 | cmd_args="$1" | |
930 | command="git $cmd_args --recurse-submodules" | |
931 | test_submodule_recursing_with_args_common "$command" | |
932 | ||
933 | RESULT=success | |
934 | if test "$KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS" = 1 | |
935 | then | |
936 | RESULT=failure | |
937 | fi | |
938 | # Switching to a commit letting a submodule appear does not care about | |
939 | # an untracked file. | |
940 | test_expect_success "$command: added submodule does remove untracked unignored file with same name when forced" ' | |
941 | prolog && | |
942 | reset_work_tree_to_interested no_submodule && | |
943 | ( | |
944 | cd submodule_update && | |
945 | git branch -t add_sub1 origin/add_sub1 && | |
946 | >sub1 && | |
947 | $command add_sub1 && | |
948 | test_superproject_content origin/add_sub1 && | |
949 | test_submodule_content sub1 origin/add_sub1 | |
259f3ee2 SB |
950 | ) |
951 | ' | |
a0500447 | 952 | |
259f3ee2 SB |
953 | # Replacing a submodule with files in a directory ... |
954 | test_expect_success "$command: replace submodule with a directory" ' | |
955 | prolog && | |
956 | reset_work_tree_to_interested add_sub1 && | |
957 | ( | |
958 | cd submodule_update && | |
959 | git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && | |
960 | $command replace_sub1_with_directory && | |
961 | test_superproject_content origin/replace_sub1_with_directory | |
962 | ) | |
963 | ' | |
964 | # ... absorbing a .git directory. | |
965 | test_expect_success "$command: replace submodule containing a .git directory with a directory must fail" ' | |
966 | prolog && | |
967 | reset_work_tree_to_interested add_sub1 && | |
968 | ( | |
969 | cd submodule_update && | |
970 | git branch -t replace_sub1_with_directory origin/replace_sub1_with_directory && | |
971 | replace_gitfile_with_git_dir sub1 && | |
972 | rm -rf .git/modules/sub1 && | |
973 | $command replace_sub1_with_directory && | |
974 | test_superproject_content origin/replace_sub1_with_directory && | |
259f3ee2 SB |
975 | test_git_directory_exists sub1 |
976 | ) | |
977 | ' | |
259f3ee2 SB |
978 | |
979 | # ... even if the submodule contains ignored files | |
980 | test_expect_success "$command: replace submodule with a file ignoring ignored files" ' | |
981 | prolog && | |
982 | reset_work_tree_to_interested add_sub1 && | |
983 | ( | |
984 | cd submodule_update && | |
985 | git branch -t replace_sub1_with_file origin/replace_sub1_with_file && | |
986 | : >sub1/expect && | |
987 | $command replace_sub1_with_file && | |
988 | test_superproject_content origin/replace_sub1_with_file | |
989 | ) | |
990 | ' | |
991 | ||
259f3ee2 | 992 | # Updating a submodule from an invalid sha1 updates |
f2d48994 | 993 | test_expect_success "$command: modified submodule does update submodule work tree from invalid commit" ' |
259f3ee2 SB |
994 | prolog && |
995 | reset_work_tree_to_interested invalid_sub1 && | |
996 | ( | |
997 | cd submodule_update && | |
998 | git branch -t valid_sub1 origin/valid_sub1 && | |
f2d48994 SB |
999 | $command valid_sub1 && |
1000 | test_superproject_content origin/valid_sub1 && | |
1001 | test_submodule_content sub1 origin/valid_sub1 | |
1002 | ) | |
1003 | ' | |
1004 | ||
1005 | # Old versions of Git were buggy writing the .git link file | |
1006 | # (e.g. before f8eaa0ba98b and then moving the superproject repo | |
1007 | # whose submodules contained absolute paths) | |
1008 | test_expect_success "$command: updating submodules fixes .git links" ' | |
1009 | prolog && | |
1010 | reset_work_tree_to_interested add_sub1 && | |
1011 | ( | |
1012 | cd submodule_update && | |
1013 | git branch -t modify_sub1 origin/modify_sub1 && | |
1014 | echo "gitdir: bogus/path" >sub1/.git && | |
1015 | $command modify_sub1 && | |
1016 | test_superproject_content origin/modify_sub1 && | |
1017 | test_submodule_content sub1 origin/modify_sub1 | |
259f3ee2 SB |
1018 | ) |
1019 | ' | |
7dcc1f4d SB |
1020 | |
1021 | test_expect_success "$command: changed submodule worktree is reset" ' | |
1022 | prolog && | |
1023 | reset_work_tree_to_interested add_sub1 && | |
1024 | ( | |
1025 | cd submodule_update && | |
1026 | rm sub1/file1 && | |
1027 | : >sub1/new_file && | |
1028 | git -C sub1 add new_file && | |
1029 | $command HEAD && | |
1030 | test_path_is_file sub1/file1 && | |
1031 | test_path_is_missing sub1/new_file | |
1032 | ) | |
1033 | ' | |
259f3ee2 | 1034 | } |