rm: better document side effects when removing a submodule
authorJens Lehmann <Jens.Lehmann@web.de>
Tue, 7 Jan 2014 21:32:37 +0000 (22:32 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 7 Jan 2014 22:34:06 +0000 (14:34 -0800)
The "Submodules" section of the "git rm" documentation mentions what will
happen when a submodule with a gitfile gets removed with newer git. But it
doesn't talk about what happens when the user changes between commits
before and after the removal, which does not remove the submodule from the
work tree like using the rm 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.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-rm.txt
t/t3600-rm.sh
index 9d731b453d1af4cbdbf559b72e8064a77696f4a3..f1efc116ebb88a3bc31898f6a18837f8b951ad09 100644 (file)
@@ -170,6 +170,15 @@ of files and subdirectories under the `Documentation/` directory.
        (i.e. you are listing the files explicitly), it
        does not remove `subdir/git-foo.sh`.
 
+BUGS
+----
+Each time a superproject update removes a populated submodule
+(e.g. when switching between commits before and after the removal) a
+stale submodule checkout will remain in the old location. Removing the
+old directory is only safe when it uses a gitfile, as otherwise the
+history of the submodule will be deleted too. This step will be
+obsolete when recursive submodule update has been implemented.
+
 SEE ALSO
 --------
 linkgit:git-add[1]
index 540c49bab618ffb75dd789b098ef982634648f7c..3d305814b9d755a827d27ed9036ebb2f8d48abe6 100755 (executable)
@@ -705,6 +705,22 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
        rm -rf submod
 '
 
+test_expect_success 'checking out a commit after submodule removal needs manual updates' '
+       git commit -m "submodule removal" submod &&
+       git checkout HEAD^ &&
+       git submodule update &&
+       git checkout -q HEAD^ 2>actual &&
+       git checkout -q master 2>actual &&
+       echo "warning: unable to rmdir submod: Directory not empty" >expected &&
+       test_i18ncmp expected actual &&
+       git status -s submod >actual &&
+       echo "?? submod/" >expected &&
+       test_cmp expected actual &&
+       rm -rf submod &&
+       git status -s -uno --ignore-submodules=none > actual &&
+       ! test -s actual
+'
+
 test_expect_success 'rm of d/f when d has become a non-directory' '
        rm -rf d &&
        mkdir d &&