public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Stefan Beller <sbeller@google•com>
Cc: git@vger•kernel.org, bmwill@google•com,
	David.Turner@twosigma•com, sandals@crustytoothpaste•net,
	j6t@kdbg•org
Subject: Re: [PATCHv5 4/4] rm: absorb a submodules git dir before deletion
Date: Mon, 26 Dec 2016 17:10:49 -0800	[thread overview]
Message-ID: <xmqqmvfich2e.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161220232012.15997-5-sbeller@google.com> (Stefan Beller's message of "Tue, 20 Dec 2016 15:20:12 -0800")

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. 

> @@ -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?

  reply	other threads:[~2016-12-27  1:11 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 [this message]
2016-12-27 18:17     ` Stefan Beller
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

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

  git send-email \
    --in-reply-to=xmqqmvfich2e.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=David.Turner@twosigma$(echo .)com \
    --cc=bmwill@google$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=j6t@kdbg$(echo .)org \
    --cc=sandals@crustytoothpaste$(echo .)net \
    --cc=sbeller@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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