git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Dennis Kaarsemaker <dennis@kaarsemaker.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3 1/2] diff --no-index: optionally follow symlinks
Date: Mon, 20 Mar 2017 11:50:35 +0100	[thread overview]
Message-ID: <1490007035.15470.14.camel@kaarsemaker.net> (raw)
In-Reply-To: <xmqqk27kzzfm.fsf@gitster.mtv.corp.google.com>

On Sun, 2017-03-19 at 15:14 -0700, Junio C Hamano wrote:
> Dennis Kaarsemaker <dennis@kaarsemaker.net> writes:
> 
> > diff --git a/diff.c b/diff.c
> > index be11e4ef2b..2afecfb939 100644
> > --- a/diff.c
> > +++ b/diff.c
> > @@ -2815,7 +2815,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
> >  		s->size = xsize_t(st.st_size);
> >  		if (!s->size)
> >  			goto empty;
> > -		if (S_ISLNK(st.st_mode)) {
> > +		if (S_ISLNK(s->mode)) {
> >  			struct strbuf sb = STRBUF_INIT;
> >  
> >  			if (strbuf_readlink(&sb, s->path, s->size))
> > @@ -2825,6 +2825,10 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
> >  			s->should_free = 1;
> >  			return 0;
> >  		}
> > +		if (S_ISLNK(st.st_mode)) {
> > +			stat(s->path, &st);
> > +			s->size = xsize_t(st.st_size);
> 
> Doesn't this affect --no-index mode?  We never need to do a wasteful
> stat() after lstat() and we are penalizing the normal codepath with
> this change, no?

the S_ISLNK(s->mode) conditional above is for the normal codepath,
which returns early. So the stat I added is only done for symlinks in
no_index mode.

> > @@ -3884,7 +3888,11 @@ int diff_opt_parse(struct diff_options *options,
> >  	else if (!strcmp(arg, "--no-follow")) {
> >  		DIFF_OPT_CLR(options, FOLLOW_RENAMES);
> >  		DIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES);
> > -	} else if (!strcmp(arg, "--color"))
> > +	} else if (!strcmp(arg, "--dereference"))
> > +		DIFF_OPT_SET(options, DEREFERENCE);
> > +	else if (!strcmp(arg, "--no-dereference"))
> > +		DIFF_OPT_CLR(options, DEREFERENCE);
> > +	else if (!strcmp(arg, "--color"))
> >  		options->use_color = 1;
> 
> Also shouldn't be some code to detect --[no-]dereference options
> given when --no-index is not in effect and error out?  As the patch
> title says, this change should be a no-op for normal codepath and
> only affect the no-index hack.

But erroring out isn't a no-op. With the current patch you can do 
--dereference without --no-index and it simply wouldn't affect
anything. 

I don't mind either way, so I'll make it error out.
-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net

  reply	other threads:[~2017-03-20 10:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 21:00 [PATCH v3 0/2] diff --no-index: support symlinks and pipes Dennis Kaarsemaker
2017-03-18 21:00 ` [PATCH v3 1/2] diff --no-index: optionally follow symlinks Dennis Kaarsemaker
2017-03-19 22:14   ` Junio C Hamano
2017-03-20 10:50     ` Dennis Kaarsemaker [this message]
2017-03-18 21:00 ` [PATCH v3 2/2] diff --no-index: support reading from pipes Dennis Kaarsemaker
2017-03-19 22:08 ` [PATCH v3 0/2] diff --no-index: support symlinks and pipes Junio C Hamano
2017-03-20 10:40   ` Dennis Kaarsemaker
2017-03-20 16:02     ` 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=1490007035.15470.14.camel@kaarsemaker.net \
    --to=dennis@kaarsemaker.net \
    --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).