mv: better document side effects when moving a submodule

The "Submodules" section of the "git mv" documentation mentions what will happen when a submodule with a gitfile gets moved with newer git. But it doesn't talk about what happens when the user changes between commits before and after the move, which does not update the work tree like using the mv command did the first time. Explain what happens and what the user has to do manually to fix that in the new BUGS section. Also document this behavior in a new test. Reported-by: George Papanikolaou <g3orge.app@gmail.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jens Lehmann committed Jan 7, 2014 at 22:31 UTC 1cbd18300a8755ba46791b2aa6249fa537a1d651
2 files changed +33
Documentation/git-mv.txt
+12
@@ -52,6 +52,18 @@ core.worktree setting to make the submodule work in the new location.
52 It also will attempt to update the submodule.<name>.path setting in
53 the linkgit:gitmodules[5] file and stage that file (unless -n is used).
54
55 +BUGS
56 +----
57 +Each time a superproject update moves a populated submodule (e.g. when
58 +switching between commits before and after the move) a stale submodule
59 +checkout will remain in the old location and an empty directory will
60 +appear in the new location. To populate the submodule again in the new
61 +location the user will have to run "git submodule update"
62 +afterwards. Removing the old directory is only safe when it uses a
63 +gitfile, as otherwise the history of the submodule will be deleted
64 +too. Both steps will be obsolete when recursive submodule update has
65 +been implemented.
66 +
67 GIT
68 ---
69 Part of the linkgit:git[1] suite
t/t7001-mv.sh
+21
@@ -442,4 +442,25 @@ test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
442 git diff-files --quiet -- sub .gitmodules
443 '
444
445 +test_expect_success 'checking out a commit before submodule moved needs manual updates' '
446 + git mv sub sub2 &&
447 + git commit -m "moved sub to sub2" &&
448 + git checkout -q HEAD^ 2>actual &&
449 + echo "warning: unable to rmdir sub2: Directory not empty" >expected &&
450 + test_i18ncmp expected actual &&
451 + git status -s sub2 >actual &&
452 + echo "?? sub2/" >expected &&
453 + test_cmp expected actual &&
454 + ! test -f sub/.git &&
455 + test -f sub2/.git &&
456 + git submodule update &&
457 + test -f sub/.git &&
458 + rm -rf sub2 &&
459 + git diff-index --exit-code HEAD &&
460 + git update-index --refresh &&
461 + git diff-files --quiet -- sub .gitmodules &&
462 + git status -s sub2 >actual &&
463 + ! test -s actual
464 +'
465 +
466 test_done