From: Stefan Beller <sbeller@google.com>
To: Per Cederqvist <cederp@opera.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH 10/10] submodule deinit: complain when given a file instead of a submodule
Date: Mon, 2 May 2016 09:21:56 -0700 [thread overview]
Message-ID: <CAGZ79kZbb=PuTwfagDZETkFEaq-3Fp4Bd7ex03TMixUDLtZtiA@mail.gmail.com> (raw)
In-Reply-To: <CAP=KgsStNm7eUWRfzDPje8mAQ2hFCMJ6MpCeF_OgPvir244vgQ@mail.gmail.com>
On Mon, May 2, 2016 at 1:26 AM, Per Cederqvist <cederp@opera.com> wrote:
> After this change, what is the simplest way to programmatically
> deinit any submodule that may exist, without failing if there are
> none?
>
> "git commit" by default refuses to make an empty commit, but
> it has the --allow-empty option.
>
> "git rm -r ." by default fails if there are no files in the repository,
> but it has the --ignore-unmatch option.
>
> It makes sense that "git submodule deinit ." should fail if there
> are no submodules, but please add support for --ignore-unmatch
> at the same time.
Oh right. I'll add the --ignore-unmatch option when rerolling this series.
Thanks,
Stefan
>
> /ceder
>
>
> On Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller <sbeller@google.com> wrote:
>> This also improves performance for listing submodules, because
>> S_ISGITLINK is both faster as match_pathspec as well as expected to
>> be true in fewer cases, so putting it first in the condition will speed
>> up the loop to compute all submodules.
>>
>> As this partially reverts 84ba959bbdf0 (submodule: fix regression for
>> deinit without submodules, 2016-03-22), this also disallows the use
>> of `git submodule deinit .` to deinit all submodules, when no
>> submodules are present. `deinit .` continues to work on repositories,
>> which have at least one submodule.
>>
>> CC: Per Cederqvist <cederp@opera.com>
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>
>>
>>> Patch 10 is a controversial thing I'd assume as it breaks existing users.
>>> We should take it for the next major release (i.e. 3.0)
>>> I just want to put it out here now.
>>
>> builtin/submodule--helper.c | 6 +++---
>> t/t7400-submodule-basic.sh | 15 ++++++++++++++-
>> 2 files changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
>> index 7f0941d..e41de3e 100644
>> --- a/builtin/submodule--helper.c
>> +++ b/builtin/submodule--helper.c
>> @@ -242,9 +242,9 @@ static int module_list_compute(int argc, const char **argv,
>> for (i = 0; i < active_nr; i++) {
>> const struct cache_entry *ce = active_cache[i];
>>
>> - if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
>> - 0, ps_matched, 1) ||
>> - !S_ISGITLINK(ce->ce_mode))
>> + if (!S_ISGITLINK(ce->ce_mode) ||
>> + !match_pathspec(pathspec, ce->name, ce_namelen(ce),
>> + 0, ps_matched, 1))
>> continue;
>>
>> ALLOC_GROW(list->entries, list->nr + 1, list->alloc);
>> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
>> index 53644da..361e6f6 100755
>> --- a/t/t7400-submodule-basic.sh
>> +++ b/t/t7400-submodule-basic.sh
>> @@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '
>> >file &&
>> git add file &&
>> git commit -m "repo should not be empty" &&
>> - git submodule deinit .
>> + git submodule deinit
>> + )
>> +'
>> +
>> +test_expect_success 'submodule deinit refuses to deinit a file' '
>> + test_when_finished "rm -rf newdirectory" &&
>> + mkdir newdirectory &&
>> + (
>> + cd newdirectory &&
>> + git init &&
>> + >file &&
>> + git add file &&
>> + git commit -m "repo should not be empty" &&
>> + test_must_fail git submodule deinit file
>> )
>> '
>>
>> --
>> 2.8.0.32.g71f8beb.dirty
>>
next prev parent reply other threads:[~2016-05-02 16:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-30 0:40 [PATCH 00/10] submodule output patches Stefan Beller
2016-04-30 0:40 ` [PATCH 01/10] submodule deinit test: fix broken && chain in subshell Stefan Beller
2016-04-30 0:40 ` [PATCH 02/10] submodule deinit: lose requirement for giving '.' Stefan Beller
2016-04-30 0:40 ` [PATCH 03/10] submodule init: redirect stdout to stderr Stefan Beller
2016-04-30 0:40 ` [PATCH 04/10] shell helpers usage: always send help " Stefan Beller
2016-05-02 23:28 ` Junio C Hamano
2016-05-02 23:44 ` Stefan Beller
2016-05-03 0:45 ` Junio C Hamano
2016-05-03 1:17 ` Junio C Hamano
2016-04-30 0:40 ` [PATCH 05/10] submodule add: send messages " Stefan Beller
2016-05-02 23:26 ` Junio C Hamano
2016-04-30 0:40 ` [PATCH 06/10] submodule deinit: " Stefan Beller
2016-05-02 23:28 ` Junio C Hamano
2016-04-30 0:40 ` [PATCH 07/10] submodule foreach: " Stefan Beller
2016-04-30 0:40 ` [PATCH 08/10] submodule update: " Stefan Beller
2016-04-30 0:40 ` [PATCH 09/10] submodule sync: " Stefan Beller
2016-04-30 0:40 ` [PATCH 10/10] submodule deinit: complain when given a file instead of a submodule Stefan Beller
2016-05-02 8:26 ` Per Cederqvist
2016-05-02 16:21 ` Stefan Beller [this message]
2016-05-02 17:00 ` Stefan Beller
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGZ79kZbb=PuTwfagDZETkFEaq-3Fp4Bd7ex03TMixUDLtZtiA@mail.gmail.com' \
--to=sbeller@google.com \
--cc=Jens.Lehmann@web.de \
--cc=cederp@opera.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).