From: Jens Lehmann <Jens.Lehmann@web.de>
To: Patrick Steinhardt <ps@pks.im>, Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org, Heiko Voigt <hvoigt@hvoigt.net>
Subject: Re: [RFC] git submodule purge
Date: Mon, 23 Mar 2015 22:32:27 +0100 [thread overview]
Message-ID: <5510866B.40501@web.de> (raw)
In-Reply-To: <20150317075636.GA354@pks-pc>
Am 17.03.2015 um 08:56 schrieb Patrick Steinhardt:
> On Mon, Mar 16, 2015 at 01:03:53PM -0700, Jonathan Nieder wrote:
>> (+cc: Jens and Heiko, submodule experts)
>> Hi,
>>
>> Patrick Steinhardt wrote:
>>
>>> This proposal is just for discussion. If there is any interest I
>>> will implement the feature and send some patches.
>>>
>>> Currently it is hard to properly remove submodules. That is when
>>> a submodule is deinitialized and removed from a repository the
>>> directory '.git/modules/<SM_NAME>' will still be present and
>>> there is no way to remove it despite manually calling `rm` on it.
>>> I think there should be a command that is able to remove those
>>> dangling repositories if the following conditions are met:
>>>
>>> - the submodule should not be initialized
>>>
>>> - the submodule should not have an entry in .gitmodules in the
>>> currently checked out revision
>>>
>>> - the submodule should not contain any commits that are not
>>> upstream
>>>
>>> - the submodule should not contain other submodules that do not
>>> meet those conditions
>>>
>>> This would ensure that it is hard to loose any commits that may
>>> be of interest. In the case that the user knows what he is doing
>>> we may provide a '--force' switch to override those checks.
>>
>> Those conditions look simultaneously too strong and too weak. ;-)
>>
>> In principle, it should be safe to remove .git/modules/<name> as
>> long as
>>
>> (1) it (and its submodules, sub-sub-modules, etc) doesn't have any
>> un-pushed local commits.
>>
>> (2) it is not being referred to by a .git file in the work tree of
>> the parent repository.
>>
>> Condition (1) can be relaxed if the user knows what they are losing
>> and is okay with that. Condition (2) can be avoided by removing
>> (de-initing) the copy of that submodule in the worktree at the same
>> time.
>>
>> The functionality sounds like a useful thing to have, whether as an
>> option to 'git submodule deinit' or as a new subcommand. In the long
>> term I would like it to be possible to do everything 'git submodule'
>> can do using normal git commands instead of that specialized
>> interface. What command do you think this would eventually belong in?
>> (An option to "git gc", maybe?)
>>
>> Thanks,
>> Jonathan
>
> Thanks for your feedback.
>
> Considering that purging the submodule is tightly coupled with
> de-initializing it, it might make sense to provide this
> functionality as part of `git submodule deinit`. Maybe something
> like `git submodule deinit --purge` would work for the user.
> Problem is if the user first removes the submodule and does not
> first deinitialize it he is not able to purge the repository
> afterwards as deinit will complain about the submodule not being
> matched anymore. We could just make `deinit --purge` work with
> removed submodules, but that does not feel very natural to me.
Hmm, cmd_deinit() seems to cope with submodules removed by the
user just fine (as long as they are still present in the index).
To me it feels natural to extend deinit to remove the repo from
.git/modules too when --purge is given (as long as no unpushed
commits are present or -f is given).
> `git gc` feels saner in that regard, but I don't think it would
> be easy to spot for users as this command is in general not used
> very frequently by them. One could argue though that it does not
> need to be discoverable.
The error message of "git submodule deinit --purge" for a
submodule that isn't recorded in the index anymore could point
the user to the appropriate gc command. But how do we tell gc
which submodule it should purge? "--purge=<submodule-name>"
maybe?
next prev parent reply other threads:[~2015-03-23 21:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 13:44 [RFC] git submodule purge Patrick Steinhardt
2015-03-16 15:55 ` Junio C Hamano
2015-03-17 8:18 ` Patrick Steinhardt
2015-03-17 8:25 ` Fredrik Gustafsson
2015-03-16 20:03 ` Jonathan Nieder
2015-03-17 7:56 ` Patrick Steinhardt
2015-03-23 21:32 ` Jens Lehmann [this message]
2015-03-25 9:06 ` Patrick Steinhardt
2015-03-25 19:47 ` Jens Lehmann
2015-03-26 13:30 ` Patrick Steinhardt
2015-03-26 21:48 ` Jens Lehmann
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=5510866B.40501@web.de \
--to=jens.lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=hvoigt@hvoigt.net \
--cc=jrnieder@gmail.com \
--cc=ps@pks.im \
/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).