git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: George Papanikolaou <g3orge.app@gmail.com>, git@vger.kernel.org
Subject: [PATCH v2 2/2] rm: better document side effects when removing a submodule
Date: Tue, 07 Jan 2014 22:32:37 +0100	[thread overview]
Message-ID: <52CC7275.3040907@web.de> (raw)
In-Reply-To: <52CC71E0.7010603@web.de>

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>
---
 Documentation/git-rm.txt |  9 +++++++++
 t/t3600-rm.sh            | 16 ++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
index 9d731b4..f1efc11 100644
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
@@ -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]
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 540c49b..3d30581 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -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 &&
-- 
1.8.5.2.231.gfc86eb1

      parent reply	other threads:[~2014-01-07 21:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 10:59 mv/rm submodules George Papanikolaou
2013-12-09 17:49 ` Jens Lehmann
2014-01-06 19:21   ` [PATCH] mv: better document side effects when moving a submodule Jens Lehmann
2014-01-06 22:40     ` Junio C Hamano
2014-01-07 17:57       ` Jens Lehmann
2014-01-07 21:30         ` [PATCH v2 0/2] better document side effects when [re]moving " Jens Lehmann
2014-01-07 21:31           ` [PATCH v2 1/2] mv: better document side effects when moving " Jens Lehmann
2014-01-07 21:32           ` Jens Lehmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52CC7275.3040907@web.de \
    --to=jens.lehmann@web.de \
    --cc=g3orge.app@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).