]> git.ipfire.org Git - thirdparty/git.git/commitdiff
mv: better document side effects when moving a submodule
authorJens Lehmann <Jens.Lehmann@web.de>
Tue, 7 Jan 2014 21:31:32 +0000 (22:31 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Jan 2014 22:33:04 +0000 (14:33 -0800)
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>
Documentation/git-mv.txt
t/t7001-mv.sh

index b1f79881efdd181cf996672bc47c7772f21df8fd..e4531325cd0e00000670692ee3e5a26387460d9e 100644 (file)
@@ -52,6 +52,18 @@ core.worktree setting to make the submodule work in the new location.
 It also will attempt to update the submodule.<name>.path setting in
 the linkgit:gitmodules[5] file and stage that file (unless -n is used).
 
+BUGS
+----
+Each time a superproject update moves a populated submodule (e.g. when
+switching between commits before and after the move) a stale submodule
+checkout will remain in the old location and an empty directory will
+appear in the new location. To populate the submodule again in the new
+location the user will have to run "git submodule update"
+afterwards. Removing the old directory is only safe when it uses a
+gitfile, as otherwise the history of the submodule will be deleted
+too. Both steps will be obsolete when recursive submodule update has
+been implemented.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
index 3bfdfed1f7774edb8a87864bdb6a021dc6a185ed..e3c8c2c1b8817acd85866470c6f76c4a4f8d17d7 100755 (executable)
@@ -442,4 +442,25 @@ test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
        git diff-files --quiet -- sub .gitmodules
 '
 
+test_expect_success 'checking out a commit before submodule moved needs manual updates' '
+       git mv sub sub2 &&
+       git commit -m "moved sub to sub2" &&
+       git checkout -q HEAD^ 2>actual &&
+       echo "warning: unable to rmdir sub2: Directory not empty" >expected &&
+       test_i18ncmp expected actual &&
+       git status -s sub2 >actual &&
+       echo "?? sub2/" >expected &&
+       test_cmp expected actual &&
+       ! test -f sub/.git &&
+       test -f sub2/.git &&
+       git submodule update &&
+       test -f sub/.git &&
+       rm -rf sub2 &&
+       git diff-index --exit-code HEAD &&
+       git update-index --refresh &&
+       git diff-files --quiet -- sub .gitmodules &&
+       git status -s sub2 >actual &&
+       ! test -s actual
+'
+
 test_done