rm: better document side effects when removing a submodule
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>
Jens Lehmann committed
Jan 7, 2014 at 22:32 UTC
bbad9f9314f658b5c0f302148fc9780f5788dcd8
2 files changed
+25
Documentation/git-rm.txt
+9
@@ -170,6 +170,15 @@ of files and subdirectories under the `Documentation/` directory.
170
(i.e. you are listing the files explicitly), it
171
does not remove `subdir/git-foo.sh`.
172
173
+BUGS
174
+----
175
+Each time a superproject update removes a populated submodule
176
+(e.g. when switching between commits before and after the removal) a
177
+stale submodule checkout will remain in the old location. Removing the
178
+old directory is only safe when it uses a gitfile, as otherwise the
179
+history of the submodule will be deleted too. This step will be
180
+obsolete when recursive submodule update has been implemented.
181
+
182
SEE ALSO
183
--------
184
linkgit:git-add[1]
t/t3600-rm.sh
+16
@@ -705,6 +705,22 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
705
rm -rf submod
706
'
707
708
+test_expect_success 'checking out a commit after submodule removal needs manual updates' '
709
+ git commit -m "submodule removal" submod &&
710
+ git checkout HEAD^ &&
711
+ git submodule update &&
712
+ git checkout -q HEAD^ 2>actual &&
713
+ git checkout -q master 2>actual &&
714
+ echo "warning: unable to rmdir submod: Directory not empty" >expected &&
715
+ test_i18ncmp expected actual &&
716
+ git status -s submod >actual &&
717
+ echo "?? submod/" >expected &&
718
+ test_cmp expected actual &&
719
+ rm -rf submod &&
720
+ git status -s -uno --ignore-submodules=none > actual &&
721
+ ! test -s actual
722
+'
723
+
724
test_expect_success 'rm of d/f when d has become a non-directory' '
725
rm -rf d &&
726
mkdir d &&