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

diff --cached --no-ext-diff --find-copies-harder --quiet exits with wrong status code

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Nov 8, 2025, 19:05 UTC
Message-ID
<CALnO6CBsj+aMvHJoUQ+LHAtXhcFhQeH8AuHyrX+rumur6MQQog@mail.gmail.com>

AFAICT, you need all of the mentioned options to trigger the bug. Allowing ext-diff works fine, I don't think it's triggered in non-cached diffs, and I've never seen it without --find-copies-harder. Notably, s/quiet/exit-code works just fine.

Here's a repro from git.git:
    cp git{,1}.c
    git add git1.c
    git diff --cached --no-ext-diff --quiet --find-copies-harder &&
echo 'this should exit 1!'

(And of course, ^quiet^exit-code if your shell supports it yields a different outcome)

Context: my distro applies a patch that allows
diff.renames=copies-harder. In a repo with that turned on,
git-prompt.sh stopped showing some staged changes.  Turns out it runs
git diff with all these flags (less --find-copies-harder, which is
enabled by the config option). I _have_ confirmed this bug exists in
unpatched Git, however.
Some rough debugging notes: when entering diffcore_std (or
diffcore_rename_extended's cleanup loop):
- for exit-code, diff_queued_diff.nr matches "git ls-files :/ | wc -l"
- for quiet, it's just 1 (the first file listed by git ls-files :/, AFAICT)
The only other obvious difference I spotted is that the "quick" flag
is turned on for quiet, which makes sense.

I tried to figure out who builds the queue, and it looks like it's diff_cache -> unpack_trees -> ..., where at some point for exit-code we _keep_ queuing files, but for quiet we don't.

I also saw diff_cache tweaks opts.diff_index_cached based on --find-copies-harder, but I haven't looked further to see how that affects things or what the interaction with ext-diff is.

Help welcome, thanks.
-- 
D. Ben Knoble
Next: D. Ben Knoble
Message 1 of 15 in “diff --cached --no-ext-diff --find-copies-harder --quiet exits with wrong status code”
  1. D. Ben KnobleNov 8, 2025
  2. D. Ben KnobleNov 8, 2025
  3. D. Ben KnobleNov 8, 2025
  4. diff: disabled quick optimization with --find-copies-harderRené Scharfe, Nov 9, 2025
  5. Phillip WoodNov 9, 2025
  6. René ScharfeNov 9, 2025
  7. diff: disable rename detection with --quietRené Scharfe, Nov 9, 2025
  8. D. Ben KnobleNov 9, 2025
  9. René ScharfeNov 9, 2025
  10. D. Ben KnobleNov 10, 2025
  11. Phillip WoodNov 10, 2025
  12. Jeff KingNov 10, 2025
  13. Junio C HamanoNov 10, 2025
  14. René ScharfeNov 22, 2025
  15. Junio C HamanoNov 23, 2025

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.