]>
Commit | Line | Data |
---|---|---|
8bf2c69c AR |
1 | #!/bin/sh |
2 | ||
5be60078 | 3 | test_description='git mv in subdirs' |
8bf2c69c | 4 | . ./test-lib.sh |
1c720357 | 5 | . "$TEST_DIRECTORY"/lib-diff-data.sh |
8bf2c69c | 6 | |
b1c8ac39 | 7 | index_at_path () { |
a9ea5296 | 8 | git ls-files --format='%(objectmode) %(objectname) %(stage)' "$@" |
b1c8ac39 JK |
9 | } |
10 | ||
b7f9130a VD |
11 | test_expect_success 'mv -f refreshes updated index entry' ' |
12 | echo test >bar && | |
13 | git add bar && | |
14 | git commit -m test && | |
15 | ||
16 | echo foo >foo && | |
17 | git add foo && | |
18 | ||
19 | # Wait one second to ensure ctime of rename will differ from original | |
20 | # file creation ctime. | |
21 | sleep 1 && | |
22 | git mv -f foo bar && | |
23 | git reset --merge HEAD && | |
24 | ||
25 | # Verify the index has been reset | |
26 | git diff-files >out && | |
27 | test_must_be_empty out | |
28 | ' | |
29 | ||
5712d62c | 30 | test_expect_success 'prepare reference tree' ' |
a76d9067 | 31 | mkdir path0 path1 && |
1c720357 | 32 | COPYING_test_data >path0/COPYING && |
a76d9067 SV |
33 | git add path0/COPYING && |
34 | git commit -m add -a | |
5712d62c | 35 | ' |
8bf2c69c | 36 | |
5712d62c | 37 | test_expect_success 'moving the file out of subdirectory' ' |
368d2782 | 38 | git -C path0 mv COPYING ../path1/COPYING |
5712d62c | 39 | ' |
8bf2c69c AR |
40 | |
41 | # in path0 currently | |
5712d62c | 42 | test_expect_success 'commiting the change' ' |
368d2782 | 43 | git commit -m move-out -a |
5712d62c | 44 | ' |
8bf2c69c | 45 | |
5712d62c | 46 | test_expect_success 'checking the commit' ' |
a76d9067 SV |
47 | git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
48 | grep "^R100..*path0/COPYING..*path1/COPYING" actual | |
5712d62c | 49 | ' |
8bf2c69c | 50 | |
5712d62c | 51 | test_expect_success 'moving the file back into subdirectory' ' |
368d2782 | 52 | git -C path0 mv ../path1/COPYING COPYING |
5712d62c | 53 | ' |
90924d55 JW |
54 | |
55 | # in path0 currently | |
5712d62c | 56 | test_expect_success 'commiting the change' ' |
368d2782 | 57 | git commit -m move-in -a |
5712d62c SV |
58 | ' |
59 | ||
60 | test_expect_success 'checking the commit' ' | |
a76d9067 SV |
61 | git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
62 | grep "^R100..*path1/COPYING..*path0/COPYING" actual | |
5712d62c SV |
63 | ' |
64 | ||
65 | test_expect_success 'mv --dry-run does not move file' ' | |
a76d9067 | 66 | git mv -n path0/COPYING MOVED && |
7cccf5b6 DO |
67 | test_path_is_file path0/COPYING && |
68 | test_path_is_missing MOVED | |
5712d62c | 69 | ' |
36b78cd9 | 70 | |
5712d62c | 71 | test_expect_success 'checking -k on non-existing file' ' |
a76d9067 | 72 | git mv -k idontexist path0 |
5712d62c | 73 | ' |
3772923f | 74 | |
5712d62c | 75 | test_expect_success 'checking -k on untracked file' ' |
d2ecddc9 | 76 | >untracked1 && |
a76d9067 | 77 | git mv -k untracked1 path0 && |
7cccf5b6 DO |
78 | test_path_is_file untracked1 && |
79 | test_path_is_missing path0/untracked1 | |
5712d62c | 80 | ' |
3772923f | 81 | |
5712d62c | 82 | test_expect_success 'checking -k on multiple untracked files' ' |
d2ecddc9 | 83 | >untracked2 && |
a76d9067 | 84 | git mv -k untracked1 untracked2 path0 && |
7cccf5b6 DO |
85 | test_path_is_file untracked1 && |
86 | test_path_is_file untracked2 && | |
87 | test_path_is_missing path0/untracked1 && | |
88 | test_path_is_missing path0/untracked2 | |
5712d62c | 89 | ' |
3772923f | 90 | |
5712d62c | 91 | test_expect_success 'checking -f on untracked file with existing target' ' |
d2ecddc9 | 92 | >path0/untracked1 && |
a76d9067 | 93 | test_must_fail git mv -f untracked1 path0 && |
7cccf5b6 DO |
94 | test_path_is_missing .git/index.lock && |
95 | test_path_is_file untracked1 && | |
96 | test_path_is_file path0/untracked1 | |
5712d62c | 97 | ' |
c8ba6b1b | 98 | |
3772923f MG |
99 | # clean up the mess in case bad things happen |
100 | rm -f idontexist untracked1 untracked2 \ | |
101 | path0/idontexist path0/untracked1 path0/untracked2 \ | |
102 | .git/index.lock | |
c57f6281 MM |
103 | rmdir path1 |
104 | ||
5712d62c | 105 | test_expect_success 'moving to absent target with trailing slash' ' |
a76d9067 SV |
106 | test_must_fail git mv path0/COPYING no-such-dir/ && |
107 | test_must_fail git mv path0/COPYING no-such-dir// && | |
108 | git mv path0/ no-such-dir/ && | |
109 | test_path_is_dir no-such-dir | |
5712d62c | 110 | ' |
c57f6281 | 111 | |
5712d62c | 112 | test_expect_success 'clean up' ' |
a76d9067 | 113 | git reset --hard |
5712d62c | 114 | ' |
c57f6281 | 115 | |
5712d62c | 116 | test_expect_success 'moving to existing untracked target with trailing slash' ' |
a76d9067 SV |
117 | mkdir path1 && |
118 | git mv path0/ path1/ && | |
119 | test_path_is_dir path1/path0/ | |
5712d62c | 120 | ' |
c57f6281 | 121 | |
5712d62c | 122 | test_expect_success 'moving to existing tracked target with trailing slash' ' |
a76d9067 SV |
123 | mkdir path2 && |
124 | >path2/file && git add path2/file && | |
125 | git mv path1/path0/ path2/ && | |
126 | test_path_is_dir path2/path0/ | |
5712d62c | 127 | ' |
c57f6281 | 128 | |
5712d62c | 129 | test_expect_success 'clean up' ' |
a76d9067 | 130 | git reset --hard |
5712d62c | 131 | ' |
3772923f | 132 | |
5712d62c | 133 | test_expect_success 'adding another file' ' |
1c720357 | 134 | COPYING_test_data | tr A-Za-z N-ZA-Mn-za-m >path0/README && |
a76d9067 SV |
135 | git add path0/README && |
136 | git commit -m add2 -a | |
5712d62c | 137 | ' |
afd22296 | 138 | |
5712d62c | 139 | test_expect_success 'moving whole subdirectory' ' |
a76d9067 | 140 | git mv path0 path2 |
5712d62c | 141 | ' |
afd22296 | 142 | |
5712d62c | 143 | test_expect_success 'commiting the change' ' |
a76d9067 | 144 | git commit -m dir-move -a |
5712d62c | 145 | ' |
afd22296 | 146 | |
5712d62c | 147 | test_expect_success 'checking the commit' ' |
a76d9067 SV |
148 | git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
149 | grep "^R100..*path0/COPYING..*path2/COPYING" actual && | |
150 | grep "^R100..*path0/README..*path2/README" actual | |
5712d62c | 151 | ' |
afd22296 | 152 | |
5712d62c | 153 | test_expect_success 'succeed when source is a prefix of destination' ' |
a76d9067 | 154 | git mv path2/COPYING path2/COPYING-renamed |
5712d62c | 155 | ' |
1d6249e6 | 156 | |
5712d62c | 157 | test_expect_success 'moving whole subdirectory into subdirectory' ' |
a76d9067 | 158 | git mv path2 path1 |
5712d62c | 159 | ' |
a1dad607 | 160 | |
5712d62c | 161 | test_expect_success 'commiting the change' ' |
a76d9067 | 162 | git commit -m dir-move -a |
5712d62c | 163 | ' |
a1dad607 | 164 | |
5712d62c | 165 | test_expect_success 'checking the commit' ' |
a76d9067 SV |
166 | git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
167 | grep "^R100..*path2/COPYING..*path1/path2/COPYING" actual && | |
168 | grep "^R100..*path2/README..*path1/path2/README" actual | |
5712d62c | 169 | ' |
a1dad607 | 170 | |
5712d62c | 171 | test_expect_success 'do not move directory over existing directory' ' |
5d683c3f SV |
172 | mkdir path0 && |
173 | mkdir path0/path2 && | |
174 | test_must_fail git mv path2 path0 | |
5712d62c | 175 | ' |
ac64a722 | 176 | |
5712d62c | 177 | test_expect_success 'move into "."' ' |
a76d9067 | 178 | git mv path1/path2/ . |
5712d62c | 179 | ' |
c5203bdf | 180 | |
4fddf579 JH |
181 | test_expect_success "Michael Cassar's test case" ' |
182 | rm -fr .git papers partA && | |
5c94f87e | 183 | git init && |
4fddf579 | 184 | mkdir -p papers/unsorted papers/all-papers partA && |
dd721541 SV |
185 | echo a >papers/unsorted/Thesis.pdf && |
186 | echo b >partA/outline.txt && | |
187 | echo c >papers/unsorted/_another && | |
4fddf579 | 188 | git add papers partA && |
36b4697f | 189 | T1=$(git write-tree) && |
4fddf579 JH |
190 | |
191 | git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf && | |
192 | ||
36b4697f | 193 | T=$(git write-tree) && |
b1c8ac39 | 194 | git ls-tree -r $T >out && |
8ddfce71 | 195 | grep partA/outline.txt out |
4fddf579 JH |
196 | ' |
197 | ||
aca085e5 JS |
198 | rm -fr papers partA path? |
199 | ||
200 | test_expect_success "Sergey Vlasov's test case" ' | |
201 | rm -fr .git && | |
5c94f87e | 202 | git init && |
aca085e5 JS |
203 | mkdir ab && |
204 | date >ab.c && | |
205 | date >ab/d && | |
206 | git add ab.c ab && | |
c76b84a1 | 207 | git commit -m "initial" && |
aca085e5 JS |
208 | git mv ab a |
209 | ' | |
210 | ||
9bcaeb71 SV |
211 | test_expect_success 'absolute pathname' ' |
212 | ( | |
213 | rm -fr mine && | |
214 | mkdir mine && | |
215 | cd mine && | |
216 | test_create_repo one && | |
217 | cd one && | |
218 | mkdir sub && | |
219 | >sub/file && | |
220 | git add sub/file && | |
221 | ||
222 | git mv sub "$(pwd)/in" && | |
7cccf5b6 DO |
223 | test_path_is_missing sub && |
224 | test_path_is_dir in && | |
9bcaeb71 SV |
225 | git ls-files --error-unmatch in/file |
226 | ) | |
227 | ' | |
744dacd3 | 228 | |
9bcaeb71 SV |
229 | test_expect_success 'absolute pathname outside should fail' ' |
230 | ( | |
231 | rm -fr mine && | |
232 | mkdir mine && | |
233 | cd mine && | |
234 | out=$(pwd) && | |
235 | test_create_repo one && | |
236 | cd one && | |
237 | mkdir sub && | |
238 | >sub/file && | |
239 | git add sub/file && | |
240 | ||
241 | test_must_fail git mv sub "$out/out" && | |
7cccf5b6 DO |
242 | test_path_is_dir sub && |
243 | test_path_is_missing ../in && | |
9bcaeb71 SV |
244 | git ls-files --error-unmatch sub/file |
245 | ) | |
246 | ' | |
744dacd3 | 247 | |
af82559b JH |
248 | test_expect_success 'git mv to move multiple sources into a directory' ' |
249 | rm -fr .git && git init && | |
250 | mkdir dir other && | |
251 | >dir/a.txt && | |
252 | >dir/b.txt && | |
253 | git add dir/?.txt && | |
254 | git mv dir/a.txt dir/b.txt other && | |
255 | git ls-files >actual && | |
39252c83 SV |
256 | cat >expect <<-\EOF && |
257 | other/a.txt | |
258 | other/b.txt | |
259 | EOF | |
af82559b JH |
260 | test_cmp expect actual |
261 | ' | |
262 | ||
81dc2307 | 263 | test_expect_success 'git mv should not change sha1 of moved cache entry' ' |
81dc2307 PB |
264 | rm -fr .git && |
265 | git init && | |
266 | echo 1 >dirty && | |
267 | git add dirty && | |
b1c8ac39 | 268 | entry="$(index_at_path dirty)" && |
81dc2307 | 269 | git mv dirty dirty2 && |
b1c8ac39 | 270 | test "$entry" = "$(index_at_path dirty2)" && |
81dc2307 PB |
271 | echo 2 >dirty2 && |
272 | git mv dirty2 dirty && | |
b1c8ac39 | 273 | test "$entry" = "$(index_at_path dirty)" |
81dc2307 PB |
274 | ' |
275 | ||
276 | rm -f dirty dirty2 | |
277 | ||
9b906af6 CT |
278 | # NB: This test is about the error message |
279 | # as well as the failure. | |
280 | test_expect_success 'git mv error on conflicted file' ' | |
281 | rm -fr .git && | |
282 | git init && | |
283 | >conflict && | |
284 | test_when_finished "rm -f conflict" && | |
285 | cfhash=$(git hash-object -w conflict) && | |
286 | q_to_tab <<-EOF | git update-index --index-info && | |
287 | 0 $cfhash 0Qconflict | |
288 | 100644 $cfhash 1Qconflict | |
289 | EOF | |
290 | ||
291 | test_must_fail git mv conflict newname 2>actual && | |
292 | test_i18ngrep "conflicted" actual | |
293 | ' | |
294 | ||
889c6f0e | 295 | test_expect_success 'git mv should overwrite symlink to a file' ' |
81dc2307 PB |
296 | rm -fr .git && |
297 | git init && | |
298 | echo 1 >moved && | |
889c6f0e JS |
299 | test_ln_s_add moved symlink && |
300 | git add moved && | |
81dc2307 PB |
301 | test_must_fail git mv moved symlink && |
302 | git mv -f moved symlink && | |
7cccf5b6 DO |
303 | test_path_is_missing moved && |
304 | test_path_is_file symlink && | |
81dc2307 | 305 | test "$(cat symlink)" = 1 && |
65c35b22 | 306 | git update-index --refresh && |
81dc2307 | 307 | git diff-files --quiet |
81dc2307 PB |
308 | ' |
309 | ||
310 | rm -f moved symlink | |
311 | ||
889c6f0e | 312 | test_expect_success 'git mv should overwrite file with a symlink' ' |
81dc2307 PB |
313 | rm -fr .git && |
314 | git init && | |
315 | echo 1 >moved && | |
889c6f0e JS |
316 | test_ln_s_add moved symlink && |
317 | git add moved && | |
81dc2307 PB |
318 | test_must_fail git mv symlink moved && |
319 | git mv -f symlink moved && | |
7cccf5b6 | 320 | test_path_is_missing symlink && |
65c35b22 | 321 | git update-index --refresh && |
81dc2307 | 322 | git diff-files --quiet |
81dc2307 PB |
323 | ' |
324 | ||
889c6f0e | 325 | test_expect_success SYMLINKS 'check moved symlink' ' |
7cccf5b6 | 326 | test_path_is_symlink moved |
889c6f0e JS |
327 | ' |
328 | ||
81dc2307 PB |
329 | rm -f moved symlink |
330 | ||
11502468 | 331 | test_expect_success 'setup submodule' ' |
0d3beb71 | 332 | test_config_global protocol.file.allow always && |
11502468 JL |
333 | git commit -m initial && |
334 | git reset --hard && | |
335 | git submodule add ./. sub && | |
336 | echo content >file && | |
337 | git add file && | |
fb8a4e80 | 338 | git commit -m "added sub and file" && |
2e3a16b2 VS |
339 | mkdir -p deep/directory/hierarchy && |
340 | git submodule add ./. deep/directory/hierarchy/sub && | |
a127331c | 341 | git commit -m "added another submodule" && |
fb8a4e80 | 342 | git branch submodule |
11502468 JL |
343 | ' |
344 | ||
345 | test_expect_success 'git mv cannot move a submodule in a file' ' | |
346 | test_must_fail git mv sub file | |
347 | ' | |
348 | ||
349 | test_expect_success 'git mv moves a submodule with a .git directory and no .gitmodules' ' | |
b1c8ac39 | 350 | entry="$(index_at_path sub)" && |
11502468 JL |
351 | git rm .gitmodules && |
352 | ( | |
353 | cd sub && | |
354 | rm -f .git && | |
00764ca1 | 355 | cp -R -P -p ../.git/modules/sub .git && |
11502468 JL |
356 | GIT_WORK_TREE=. git config --unset core.worktree |
357 | ) && | |
358 | mkdir mod && | |
359 | git mv sub mod/sub && | |
7cccf5b6 | 360 | test_path_is_missing sub && |
b1c8ac39 | 361 | test "$entry" = "$(index_at_path mod/sub)" && |
368d2782 | 362 | git -C mod/sub status && |
11502468 JL |
363 | git update-index --refresh && |
364 | git diff-files --quiet | |
365 | ' | |
366 | ||
04c1ee57 JL |
367 | test_expect_success 'git mv moves a submodule with a .git directory and .gitmodules' ' |
368 | rm -rf mod && | |
369 | git reset --hard && | |
370 | git submodule update && | |
b1c8ac39 | 371 | entry="$(index_at_path sub)" && |
04c1ee57 JL |
372 | ( |
373 | cd sub && | |
374 | rm -f .git && | |
00764ca1 | 375 | cp -R -P -p ../.git/modules/sub .git && |
04c1ee57 JL |
376 | GIT_WORK_TREE=. git config --unset core.worktree |
377 | ) && | |
378 | mkdir mod && | |
379 | git mv sub mod/sub && | |
7cccf5b6 | 380 | test_path_is_missing sub && |
b1c8ac39 | 381 | test "$entry" = "$(index_at_path mod/sub)" && |
368d2782 | 382 | git -C mod/sub status && |
04c1ee57 JL |
383 | echo mod/sub >expected && |
384 | git config -f .gitmodules submodule.sub.path >actual && | |
385 | test_cmp expected actual && | |
386 | git update-index --refresh && | |
387 | git diff-files --quiet | |
388 | ' | |
389 | ||
a88c915d | 390 | test_expect_success 'git mv moves a submodule with gitfile' ' |
2b2b1e4d | 391 | rm -rf mod && |
a88c915d JL |
392 | git reset --hard && |
393 | git submodule update && | |
b1c8ac39 | 394 | entry="$(index_at_path sub)" && |
2b2b1e4d | 395 | mkdir mod && |
368d2782 | 396 | git -C mod mv ../sub/ . && |
7cccf5b6 | 397 | test_path_is_missing sub && |
b1c8ac39 | 398 | test "$entry" = "$(index_at_path mod/sub)" && |
368d2782 | 399 | git -C mod/sub status && |
0656781f JL |
400 | echo mod/sub >expected && |
401 | git config -f .gitmodules submodule.sub.path >actual && | |
402 | test_cmp expected actual && | |
a88c915d JL |
403 | git update-index --refresh && |
404 | git diff-files --quiet | |
405 | ' | |
406 | ||
0656781f | 407 | test_expect_success 'mv does not complain when no .gitmodules file is found' ' |
2b2b1e4d | 408 | rm -rf mod && |
0656781f JL |
409 | git reset --hard && |
410 | git submodule update && | |
411 | git rm .gitmodules && | |
b1c8ac39 | 412 | entry="$(index_at_path sub)" && |
2b2b1e4d | 413 | mkdir mod && |
0656781f | 414 | git mv sub mod/sub 2>actual.err && |
ec10b018 | 415 | test_must_be_empty actual.err && |
7cccf5b6 | 416 | test_path_is_missing sub && |
b1c8ac39 | 417 | test "$entry" = "$(index_at_path mod/sub)" && |
368d2782 | 418 | git -C mod/sub status && |
0656781f JL |
419 | git update-index --refresh && |
420 | git diff-files --quiet | |
421 | ' | |
422 | ||
423 | test_expect_success 'mv will error out on a modified .gitmodules file unless staged' ' | |
2b2b1e4d | 424 | rm -rf mod && |
0656781f JL |
425 | git reset --hard && |
426 | git submodule update && | |
427 | git config -f .gitmodules foo.bar true && | |
b1c8ac39 | 428 | entry="$(index_at_path sub)" && |
2b2b1e4d | 429 | mkdir mod && |
0656781f | 430 | test_must_fail git mv sub mod/sub 2>actual.err && |
7cccf5b6 DO |
431 | test_file_not_empty actual.err && |
432 | test_path_exists sub && | |
0656781f JL |
433 | git diff-files --quiet -- sub && |
434 | git add .gitmodules && | |
435 | git mv sub mod/sub 2>actual.err && | |
ec10b018 | 436 | test_must_be_empty actual.err && |
7cccf5b6 | 437 | test_path_is_missing sub && |
b1c8ac39 | 438 | test "$entry" = "$(index_at_path mod/sub)" && |
368d2782 | 439 | git -C mod/sub status && |
0656781f JL |
440 | git update-index --refresh && |
441 | git diff-files --quiet | |
442 | ' | |
443 | ||
444 | test_expect_success 'mv issues a warning when section is not found in .gitmodules' ' | |
2b2b1e4d | 445 | rm -rf mod && |
0656781f JL |
446 | git reset --hard && |
447 | git submodule update && | |
448 | git config -f .gitmodules --remove-section submodule.sub && | |
449 | git add .gitmodules && | |
b1c8ac39 | 450 | entry="$(index_at_path sub)" && |
0656781f | 451 | echo "warning: Could not find section in .gitmodules where path=sub" >expect.err && |
2b2b1e4d | 452 | mkdir mod && |
0656781f | 453 | git mv sub mod/sub 2>actual.err && |
1108cea7 | 454 | test_cmp expect.err actual.err && |
7cccf5b6 | 455 | test_path_is_missing sub && |
b1c8ac39 | 456 | test "$entry" = "$(index_at_path mod/sub)" && |
368d2782 | 457 | git -C mod/sub status && |
0656781f JL |
458 | git update-index --refresh && |
459 | git diff-files --quiet | |
460 | ' | |
461 | ||
462 | test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' ' | |
2b2b1e4d | 463 | rm -rf mod && |
0656781f JL |
464 | git reset --hard && |
465 | git submodule update && | |
2b2b1e4d | 466 | mkdir mod && |
0656781f | 467 | git mv -n sub mod/sub 2>actual.err && |
7cccf5b6 | 468 | test_path_is_file sub/.git && |
0656781f JL |
469 | git diff-index --exit-code HEAD && |
470 | git update-index --refresh && | |
471 | git diff-files --quiet -- sub .gitmodules | |
472 | ' | |
473 | ||
1cbd1830 JL |
474 | test_expect_success 'checking out a commit before submodule moved needs manual updates' ' |
475 | git mv sub sub2 && | |
476 | git commit -m "moved sub to sub2" && | |
477 | git checkout -q HEAD^ 2>actual && | |
0a288d1e | 478 | test_i18ngrep "^warning: unable to rmdir '\''sub2'\'':" actual && |
1cbd1830 JL |
479 | git status -s sub2 >actual && |
480 | echo "?? sub2/" >expected && | |
481 | test_cmp expected actual && | |
7cccf5b6 DO |
482 | test_path_is_missing sub/.git && |
483 | test_path_is_file sub2/.git && | |
1cbd1830 | 484 | git submodule update && |
7cccf5b6 | 485 | test_path_is_file sub/.git && |
1cbd1830 JL |
486 | rm -rf sub2 && |
487 | git diff-index --exit-code HEAD && | |
488 | git update-index --refresh && | |
489 | git diff-files --quiet -- sub .gitmodules && | |
490 | git status -s sub2 >actual && | |
ec10b018 | 491 | test_must_be_empty actual |
1cbd1830 JL |
492 | ' |
493 | ||
fb8a4e80 | 494 | test_expect_success 'mv -k does not accidentally destroy submodules' ' |
495 | git checkout submodule && | |
496 | mkdir dummy dest && | |
497 | git mv -k dummy sub dest && | |
498 | git status --porcelain >actual && | |
499 | grep "^R sub -> dest/sub" actual && | |
500 | git reset --hard && | |
501 | git checkout . | |
502 | ' | |
503 | ||
a127331c SB |
504 | test_expect_success 'moving a submodule in nested directories' ' |
505 | ( | |
506 | cd deep && | |
507 | git mv directory ../ && | |
508 | # git status would fail if the update of linking git dir to | |
509 | # work dir of the submodule failed. | |
510 | git status && | |
2e3a16b2 VS |
511 | git config -f ../.gitmodules submodule.deep/directory/hierarchy/sub.path >../actual && |
512 | echo "directory/hierarchy/sub" >../expect | |
a127331c | 513 | ) && |
9c5b2fab | 514 | test_cmp expect actual |
a127331c SB |
515 | ' |
516 | ||
da62f786 | 517 | test_expect_success 'moving nested submodules' ' |
0d3beb71 | 518 | test_config_global protocol.file.allow always && |
c514167d HV |
519 | git commit -am "cleanup commit" && |
520 | mkdir sub_nested_nested && | |
9bcaeb71 SV |
521 | ( |
522 | cd sub_nested_nested && | |
d2ecddc9 | 523 | >nested_level2 && |
c514167d HV |
524 | git init && |
525 | git add . && | |
526 | git commit -m "nested level 2" | |
527 | ) && | |
528 | mkdir sub_nested && | |
9bcaeb71 SV |
529 | ( |
530 | cd sub_nested && | |
d2ecddc9 | 531 | >nested_level1 && |
c514167d HV |
532 | git init && |
533 | git add . && | |
e974e06d | 534 | git commit -m "nested level 1" && |
c514167d HV |
535 | git submodule add ../sub_nested_nested && |
536 | git commit -m "add nested level 2" | |
537 | ) && | |
538 | git submodule add ./sub_nested nested_move && | |
539 | git commit -m "add nested_move" && | |
540 | git submodule update --init --recursive && | |
541 | git mv nested_move sub_nested_moved && | |
542 | git status | |
543 | ' | |
544 | ||
8bf2c69c | 545 | test_done |