git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] diff: use filespec path to set up tempfiles for ext-diff

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 6, 2023, 12:48 UTC
Message-ID
<xmqqbknbsu9y.fsf@gitster.g>
In-Reply-To
<Y7gAHenwmIo4gXTb@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> We can fix this by passing the pathname from the diff_filespec, which
> should always be a full repository path (and that's what we want even if
> reusing a worktree file, since we're always operating from the top-level
> of the working tree).
Very sensible.
> 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" ;-)

Show 9 quoted lines
> So the only bug is just the interaction with external diff drivers and
> --relative.
>
> Reported-by: Carl Baldwin <carl@ecbaldwin.net>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  diff.c                   |  2 +-
>  t/t4045-diff-relative.sh | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)

Thanks for a clear description. The fix looks trivially obvious and correct.

Show 10 quoted lines
> diff --git a/diff.c b/diff.c
> index 9b14543e6e..59039773a1 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -4281,7 +4281,7 @@ static void add_external_diff_name(struct repository *r,
>  				   const char *name,
>  				   struct diff_filespec *df)
>  {
> -	struct diff_tempfile *temp = prepare_temp_file(r, name, df);
> +	struct diff_tempfile *temp = prepare_temp_file(r, df->path, df);
Previous: Jeff KingNext: Jeff King
Message 4 of 7 in “Problem with git diff --relative, diff.external, run from a sub-directory”
  1. Carl BaldwinJan 4, 2023
  2. 0/3 fixing "diff --relative" with external diffJeff King, Jan 6, 2023
  3. 1/3 diff: use filespec path to set up tempfiles for ext-diffJeff King, Jan 6, 2023
  4. Junio C HamanoJan 6, 2023
  5. Jeff KingJan 6, 2023
  6. 2/3 diff: clean up external-diff argv setupJeff King, Jan 6, 2023
  7. 3/3 diff: drop "name" parameter from prepare_temp_file()Jeff King, Jan 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.