git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@suse.cz>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/6] git rm: Support for removing submodules
Date: Sat, 13 Sep 2008 00:24:29 +0200	[thread overview]
Message-ID: <20080912222429.GE10360@machine.or.cz> (raw)
In-Reply-To: <7v1vzpnhzj.fsf@gitster.siamese.dyndns.org> <7v8wtxniez.fsf@gitster.siamese.dyndns.org>

I will collect your feedback on the whole series, then resend it from
scratch - sounds good?

On Fri, Sep 12, 2008 at 02:49:56PM -0700, Junio C Hamano wrote:
> Petr Baudis <pasky@suse.cz> writes:
> 
> > @@ -20,7 +20,8 @@ and no updates to their contents can be staged in the index,
> >  though that default behavior can be overridden with the `-f` option.
> >  When '--cached' is given, the staged content has to
> >  match either the tip of the branch or the file on disk,
> > -allowing the file to be removed from just the index.
> > +allowing the file to be removed from just the index;
> > +this is always the case when removing submodules.
> 
> Sorry, I read this three times but "this" is unclear to me.  Different and
> mutually incompatible interpretations I tried to understand it are:
> 
>  (1) When removing submodules, whether --cached or not, the index can
>      match either HEAD or the work tree; this is different from removing
>      regular blobs where the index must match with HEAD without --cached
>      nor -f;
> 
>  (2) When removing submodules with --cached, the index can match either
>      HEAD or the work tree and it is removed only from the index.  You
>      cannot remove submodules without --cached;
> 
>  (3) When removing submodules, the index can match either HEAD or the work
>      tree and it is removed only from the index, even if you did not give
>      --cached;
> 
> It later becomes clear that you meant (3) in the second hunk, but the
> first time reader of the resulting document (not this patch) won't be
> reading from bottom to top.
> 
> This is a leftover issue from ealier documentation 25dc720 (Clarify and
> fix English in "git-rm" documentation, 2008-04-16), but the description is
> unclear what should happen while working towards the initial commit
> (i.e. no HEAD yet).  I think check_local_mod() allows removal in such a
> case.  Perhaps you can clarify the point while at it, please?

I will have a look.

> > diff --git a/builtin-rm.c b/builtin-rm.c
> > index 6bd8211..7475de2 100644
> > --- a/builtin-rm.c
> > +++ b/builtin-rm.c
> > ...
> > -static void add_list(const char *name)
> > +static void add_list(const char *name, int is_gitlink)
> >  {
> >  	if (list.nr >= list.alloc) {
> >  		list.alloc = alloc_nr(list.alloc);
> > -		list.name = xrealloc(list.name, list.alloc * sizeof(const char *));
> > +		list.info = xrealloc(list.info, list.alloc * sizeof(*list.info));
> >  	}
> 
> ALLOC_GROW()?

Neat thing!

> > @@ -38,6 +44,13 @@ static int remove_file(const char *name)
> >  	if (ret && errno == ENOENT)
> >  		/* The user has removed it from the filesystem by hand */
> >  		ret = errno = 0;
> > +	if (ret && errno == EISDIR) {
> > +		/* This is a gitlink entry; try to remove at least the
> > +		 * directory if the submodule is not checked out; we always
> > +		 * leave the checked out ones as they are */
> 
> 	/*
> 	 * Style?
>          * for a multi-line comment.
>          */

Right - I will have to get used to this. ;-)

> > +static void remove_submodule(const char *name)
> > +{
> > +	char *key = submodule_by_path(name);
> > +	char *sectend = strrchr(key, '.');
> > +
> > +	assert(sectend);
> > +	*sectend = 0;
> 
> Here is one caller I questioned in my comments on [1/6].  It is clear this
> caller wants to use "submodule.xyzzy" out of "submodule.xyzzy.path".  The
> function returning "submodule.xyzzy.path" does not feel like a clean and
> reusable interface to me.  I'd suggest either returning "submodule.xyzzy"
> (that's too specialized only for this caller to my taste, though), or just
> "xyzzy" and have the caller synthesize whatever string it wants to use
> (yes, it loses microoptimization but do we really care about it in this
> codepath?), if you have other callers that want different strings around
> "xyzzy".

This is still easier to use than explicit snprintf(), but in the long
run, you're right that returning just the submodule name is the right
thing. I will change the API.

> > @@ -140,7 +169,7 @@ static struct option builtin_rm_options[] = {
> >  
> >  int cmd_rm(int argc, const char **argv, const char *prefix)
> >  {
> > -	int i, newfd;
> > +	int i, newfd, subs;
> 
> Perhaps hoist "int removed" up one scope level and reuse it?  I misread
> that you are counting the number of gitlinks in the index, not the number
> of gitlinks that is being removed, on my first read.  The variable is used
> for the latter.

Sensible idea.

On Fri, Sep 12, 2008 at 02:59:12PM -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
> >> +{
> >> +	char *key = submodule_by_path(name);
> >> +	char *sectend = strrchr(key, '.');
> >> +
> >> +	assert(sectend);
> >> +	*sectend = 0;
> >
> > Here is one caller I questioned in my comments on [1/6]...
> 
> Another thing --- can submodule_by_path() ever return NULL saying "I do
> not see one in the configuration"?

No, it would rather die().

-- 
				Petr "Pasky" Baudis
The next generation of interesting software will be done
on the Macintosh, not the IBM PC.  -- Bill Gates

  reply	other threads:[~2008-09-12 22:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12 21:08 [PATCH 0/6] Submodule support for git mv and git rm Petr Baudis
2008-09-12 21:08 ` [PATCH 1/6] submodule.*: Introduce simple C interface for submodule lookup by path Petr Baudis
2008-09-12 21:23   ` Junio C Hamano
2008-09-12 21:35     ` Jakub Narebski
2008-09-12 21:58     ` Petr Baudis
2008-09-12 21:09 ` [PATCH 2/6] git rm: Support for removing submodules Petr Baudis
2008-09-12 21:49   ` Junio C Hamano
2008-09-12 21:59     ` Junio C Hamano
2008-09-12 22:24       ` Petr Baudis [this message]
2008-09-12 22:42         ` Junio C Hamano
2008-09-12 21:09 ` [PATCH 3/6] git mv: Support moving submodules Petr Baudis
2008-09-12 21:42   ` [PATCH] " Petr Baudis
2008-09-12 22:19     ` Junio C Hamano
2008-09-12 21:09 ` [PATCH 4/6] t7403: Submodule git mv, git rm testsuite Petr Baudis
2008-09-12 21:09 ` [PATCH 5/6] t7400: Add short "git submodule add" testsuite Petr Baudis
2008-09-12 21:09 ` [PATCH 6/6] git submodule add: Fix naming clash handling Petr Baudis
2008-09-13  2:24   ` Junio C Hamano
2008-09-13 11:32     ` Lars Hjemli

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=20080912222429.GE10360@machine.or.cz \
    --to=pasky@suse.cz \
    --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.
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).