git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Brandon Williams <bmwill@google.com>,
	David Turner <David.Turner@twosigma.com>,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCHv5 4/4] rm: absorb a submodules git dir before deletion
Date: Tue, 27 Dec 2016 10:17:33 -0800	[thread overview]
Message-ID: <CAGZ79kaRY0x+31-UiiBU1iBXGKAgeTRSSjvN0isd7jdg-Y7_rQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqmvfich2e.fsf@gitster.mtv.corp.google.com>

On Mon, Dec 26, 2016 at 5:10 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> @@ -342,6 +313,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
>>                       exit(0);
>>       }
>>
>> +     submodules_absorb_gitdir_if_needed(prefix);
>> +
>>       /*
>>        * If not forced, the file, the index and the HEAD (if exists)
>>        * must match; but the file can already been removed, since
>> @@ -358,9 +331,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
>>                       oidclr(&oid);
>>               if (check_local_mod(&oid, index_only))
>>                       exit(1);
>> -     } else if (!index_only) {
>> -             if (check_submodules_use_gitfiles())
>> -                     exit(1);
>>       }
>>
>
> Hmph.  It may be a bit strange to see an "index-only" remove to
> touch working tree, no?  Yet submodules_absorb_gitdir_if_needed() is
> unconditionally called above, which feels somewhat unexpected.

I agree. In a reroll I'll protect the call with

    if (!index_only)
        submodules_absorb_gitdir_if_needed(prefix);

>
>> @@ -389,32 +359,20 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
>>        */
>>       if (!index_only) {
>>               int removed = 0, gitmodules_modified = 0;
>>               for (i = 0; i < list.nr; i++) {
>>                       const char *path = list.entry[i].name;
>>                       if (list.entry[i].is_submodule) {
>> +                             struct strbuf buf = STRBUF_INIT;
>> +
>> +                             strbuf_addstr(&buf, path);
>> +                             if (remove_dir_recursively(&buf, 0))
>> +                                     die(_("could not remove '%s'"), path);
>> +                             strbuf_release(&buf);
>> +
>> +                             removed = 1;
>> +                             if (!remove_path_from_gitmodules(path))
>> +                                     gitmodules_modified = 1;
>> +                             continue;
>>                       }
>
> I do not see any behaviour change from the original (not quoted
> here), but it is somewhat surprising that "git rm ./submodule" does
> not really check if the submodule has local modifications and files
> that are not even added before remove_dir_recursively() is called.
>
> Or perhaps I am reading the code incorrectly and such a check is
> done elsewhere?

When determining if the entry is a submodule (i.e. setting
the is_submodule bit) we have

    list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode);
    if (list.entry[list.nr++].is_submodule &&
      !is_staging_gitmodules_ok())
        die (_("Please stage ..."));

I think for clarity we could drop the is_submodule bit and only
and directly do

    if (S_ISGITLINK(ce->ce_mode) &&
      !is_staging_gitmodules_ok())
        die (_("Please stage ..."));

and below (the code that you quoted) also just check via
    S_ISGITLINK(ce->ce_mode)

Thanks,
Stefan

  reply	other threads:[~2016-12-27 18:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-20 23:20 [PATCHv5 0/4] git-rm absorbs submodule git directory before deletion Stefan Beller
2016-12-20 23:20 ` [PATCHv5 1/4] submodule.h: add extern keyword to functions Stefan Beller
2016-12-27  1:13   ` Junio C Hamano
2016-12-27 17:59     ` Stefan Beller
2016-12-20 23:20 ` [PATCHv5 2/4] submodule: modernize ok_to_remove_submodule to use argv_array Stefan Beller
2016-12-20 23:20 ` [PATCHv5 3/4] submodule: rename and add flags to ok_to_remove_submodule Stefan Beller
2016-12-27  0:53   ` Junio C Hamano
2016-12-27 17:55     ` Stefan Beller
2016-12-20 23:20 ` [PATCHv5 4/4] rm: absorb a submodules git dir before deletion Stefan Beller
2016-12-27  1:10   ` Junio C Hamano
2016-12-27 18:17     ` Stefan Beller [this message]
2016-12-27 18:26       ` Stefan Beller
2016-12-27 21:55         ` 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

  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=CAGZ79kaRY0x+31-UiiBU1iBXGKAgeTRSSjvN0isd7jdg-Y7_rQ@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=David.Turner@twosigma.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=sandals@crustytoothpaste.net \
    /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).