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

[PATCH 0/3] fixing "diff --relative" with external diff

From
Jeff King <peff@peff.net>
Date
Jan 6, 2023, 11:00 UTC
Message-ID
<Y7f/YiVu1TgbucDI@coredump.intra.peff.net>
In-Reply-To
<CALiLy7raQsK3j+f6+dpYrEiegvFZRra5F9JwPWu---4h_AR49w@mail.gmail.com>
On Wed, Jan 04, 2023 at 03:03:17PM -0700, Carl Baldwin wrote:
Show 9 quoted lines
> What did you expect to happen? (Expected behavior)
> 
>     When using a diff.external command with --relative, the diff output should
>     show the minor change that I made to the file.
> 
> What happened instead? (Actual behavior)
> 
>     The diff output shows the entire old contents of the file as deleted. The
>     header of the patch looked like this (indent added for this report):

Nice catch, and thank you for a clear reproduction recipe. It looks like this bug has been lurking since --relative was introduced in 2008. :)

Here's a patch series which fixes it. The first one is the fix itself, and the other two are some cleanups we can do on top (I almost squashed them in, but their diffs are rather noisy and make it harder to see the actual fix).

  [1/3]: diff: use filespec path to set up tempfiles for ext-diff
  [2/3]: diff: clean up external-diff argv setup
  [3/3]: diff: drop "name" parameter from prepare_temp_file()
 diff.c                   | 30 +++++++++++++-----------------
 t/t4045-diff-relative.sh | 29 +++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 17 deletions(-)
-Peff
Previous: Carl BaldwinNext: Jeff King
Message 2 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.