All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Carl Baldwin <carl@ecbaldwin.net>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 1/3] diff: use filespec path to set up tempfiles for ext-diff
Date: Fri, 6 Jan 2023 08:10:11 -0500	[thread overview]
Message-ID: <Y7gdsxNT2TM/5M17@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqbknbsu9y.fsf@gitster.g>

On Fri, Jan 06, 2023 at 09:48:57PM +0900, Junio C Hamano wrote:

> > The breakage seems to go all the way back to cd676a5136 (diff
> > --relative: output paths as relative to the current subdirectory,
> > 2008-02-12).
> 
> Not surprising.  When I wrote all the rest of "diff", I didn't
> plan to do "--relative" ;-)

:) Commit cd676a5136 mentions that "diff --relative" does not interact
well with "--no-index", and that was one of the things I tested while
poking (to make sure I did not make anything worse). And indeed, it
seems that --relative is mostly ignored there. We could follow through
on the plan from the end of the commit message to forbid combining the
two, but it may not be that important given how long it has been an
issue (and that I think people may set diff.relative in their config
these days).

> Thanks for a clear description.  The fix looks trivially obvious and
> correct.
> [...]
> > -	struct diff_tempfile *temp = prepare_temp_file(r, name, df);
> > +	struct diff_tempfile *temp = prepare_temp_file(r, df->path, df);

One nagging concern I had is whether "df->path" might ever point to
something unexpected (or even be NULL). The fact that textconv
unconditionally passes it made me feel a lot better. But I also ended up
walking back to the source of the "name" and "other" fields, which is
this code in run_diff():

	name  = one->path;
	other = (strcmp(name, two->path) ? two->path : NULL);
	attr_path = name;
	if (o->prefix_length)
		strip_prefix(o->prefix_length, &name, &other);

So those values really are just aliases for one->path and two->path,
modulo the prefix stripping (which as you might guess, came from
cd676a5136 itself). And using them directly instead of the stripped
versions is definitely the right thing to do.

-Peff

  reply	other threads:[~2023-01-06 13:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 22:03 Problem with git diff --relative, diff.external, run from a sub-directory Carl Baldwin
2023-01-06 11:00 ` [PATCH 0/3] fixing "diff --relative" with external diff Jeff King
2023-01-06 11:03   ` [PATCH 1/3] diff: use filespec path to set up tempfiles for ext-diff Jeff King
2023-01-06 12:48     ` Junio C Hamano
2023-01-06 13:10       ` Jeff King [this message]
2023-01-06 11:04   ` [PATCH 2/3] diff: clean up external-diff argv setup Jeff King
2023-01-06 11:05   ` [PATCH 3/3] diff: drop "name" parameter from prepare_temp_file() Jeff King

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=Y7gdsxNT2TM/5M17@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=carl@ecbaldwin.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.