From: Jens Lehmann <Jens.Lehmann@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "Michał Górny" <mgorny@gentoo.org>,
"Phil Hord" <phil.hord@gmail.com>,
"Heiko Voigt" <hvoigt@hvoigt.net>
Subject: Re: [RFC PATCH 1/2] rm: don't fail when removing populated submodules
Date: Sat, 07 Jul 2012 14:51:34 +0200 [thread overview]
Message-ID: <4FF830D6.7080708@web.de> (raw)
In-Reply-To: <7v1ukppear.fsf@alter.siamese.dyndns.org>
Am 06.07.2012 08:57, schrieb Junio C Hamano:
> Jens Lehmann <Jens.Lehmann@web.de> writes:
>> Also apply the same policy as for regular files and
>> require forcing when the submodules HEAD is different than what is
>> recorded in the index.
>
> I think the "policy" for regular files is that "git rm $path" errors
> out to avoid losing information in $path. Even if the HEAD in the
> submodule points at the same commit as recorded in the index, if the
> submodule directory has other changes that (cd $path && git status)
> would report, we would not want to remove it, no?
>
> I am not sure if the difference between $path/.git/HEAD and :$path
> (the version in the index) matters. Maybe it does, maybe it
> doesn't.
Doh. I don't know how I got the idea it would be so, but a quick
test with checkout and rebase showed they ignore if a submodules
HEAD is different from the commit recorded. So plain rm should do
the same as long as it doesn't touch the submodule work tree and
I'll remove checking the HEAD from patch 1. I'll prepare v2 which
will also include an updated commit message.
> One possible sane behaviour of "git rm $path" might be:
>
> - If --force is given, remove it from the index and from the
> working tree (i.e. "rm -rf $path"), but use the "gitfile"
> facility to save $path/.git away to $GIT_DIR/modules/$name; error
> out if the submodule directory $path cannot be removed like this.
> We would probably want to remove "submodule.<name>.*" entries in
> .gitmodules for <name> for which "submodule.<name>.path" matches
> the $path.
>
> - If --cached is given, remove it from the index if the version in
> the index match either HEAD or the $path/.git/HEAD, without
> touching the working tree. This is consistent with what happens
> to a regular file.
>
> - If neither --force nor --cached is given, run an equivalent of
> (cd $path && git status), and also check if $path/.git/HEAD
> matches the index version. Error out if the submodule directory
> is dirty (again I am not sure about this part). If the submodule
> directory is clean, do the same as the case with --force.
What you describe here is exactly how I think "git submodule rm" and
"git rm --recurse-submodules" should behave.
The questions remaining for me are:
* What should a "git rm --no-recurse-submodules" do?
I think it should try to follow the policy git core commands use:
- don't touch the submodule's work tree
- remove the submodule directory if it is empty and warn if not
(currently it dies if not, to change that to a warning is the
subject of patch 1)
The more difficult question is if it should remove the submodule
entry from .gitmodules (patch 2). As that file is part of the
superproject's work tree and core git already learned to read
configuration options for status, diff and fetch from it I think
it's a good idea to help the user by doing so (but maybe we should
make this configurable and/or add an option to enable/disable it).
But on the other hand maybe users expect this only to happen when
they use "git submodule rm" and "git rm" should leave .gitmodules
alone?
* What should the default behavior of "git rm" be.
I tend to think that as all other core git commands never
manipulate a submodule's work tree without the --recurse-submodules
option, rm should do the same. So I think we should default to
the --no-recure-submodules case described above to not surprise the
user. That makes checking the submodule for modifications unnecessary
until the --recure-submodules option is implemented.
Does that make sense?
next prev parent reply other threads:[~2012-07-07 12:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-04 20:43 [RFC PATCH 0/2] Teach rm to better handle submodules Jens Lehmann
2012-07-04 20:44 ` [RFC PATCH 1/2] rm: don't fail when removing populated submodules Jens Lehmann
2012-07-06 6:57 ` Junio C Hamano
2012-07-07 12:51 ` Jens Lehmann [this message]
2012-07-08 7:32 ` Junio C Hamano
2012-07-08 15:08 ` Jens Lehmann
2012-07-09 2:17 ` Junio C Hamano
2012-07-09 5:02 ` Junio C Hamano
2012-07-09 18:33 ` Jens Lehmann
2012-07-09 19:38 ` Junio C Hamano
2012-07-09 20:23 ` Jens Lehmann
2012-08-16 21:56 ` Junio C Hamano
2012-08-17 16:44 ` Jens Lehmann
2012-08-17 18:11 ` Phil Hord
2012-08-19 19:38 ` Jens Lehmann
2012-07-04 20:44 ` [RFC PATCH 2/2] rm: remove submodules from the index and the .gitmodules file Jens Lehmann
2012-07-05 0:44 ` [RFC PATCH 0/2] Teach rm to better handle submodules Junio C Hamano
2012-07-05 19:06 ` Jens Lehmann
2012-07-05 22:10 ` Junio C Hamano
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=4FF830D6.7080708@web.de \
--to=jens.lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hvoigt@hvoigt.net \
--cc=mgorny@gentoo.org \
--cc=phil.hord@gmail.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).