From: "René Scharfe" <l.s.r@web•de>
To: "D. Ben Knoble" <ben.knoble@gmail•com>, Git <git@vger•kernel.org>
Cc: Junio C Hamano <gitster@pobox•com>, Jeff King <peff@peff•net>
Subject: [PATCH] diff: disabled quick optimization with --find-copies-harder
Date: Sun, 9 Nov 2025 13:11:39 +0100 [thread overview]
Message-ID: <bbd1a371-b0a4-4412-b329-cb4d654a0ca8@web.de> (raw)
In-Reply-To: <CALnO6CBsj+aMvHJoUQ+LHAtXhcFhQeH8AuHyrX+rumur6MQQog@mail.gmail.com>
If --find-copies-harder is given, diff-lib.c::show_modified() queues
even non-modified entries using diff_change() because we need them for
copy detection. diff_change() sets flags.has_changes, though. If
--quiet is also given this causes diff_can_quit_early() to declare we're
done after seeing only the very first entry, which is way too soon.
Disable this optimization in that case.
This issue is hidden without --no-ext-diff because then we set
flags.diff_from_contents, which disables the optimization in a
different way.
Reported-by: D. Ben Knoble <ben.knoble@gmail•com>
Signed-off-by: René Scharfe <l.s.r@web•de>
---
diff.c | 1 +
t/t4007-rename-3.sh | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/diff.c b/diff.c
index a1961526c0..84ac148c37 100644
--- a/diff.c
+++ b/diff.c
@@ -7188,6 +7188,7 @@ int diff_can_quit_early(struct diff_options *opt)
{
return (opt->flags.quick &&
!opt->filter &&
+ !opt->flags.find_copies_harder &&
opt->flags.has_changes);
}
diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh
index e8faf0dd2e..3fc81bcd76 100755
--- a/t/t4007-rename-3.sh
+++ b/t/t4007-rename-3.sh
@@ -41,6 +41,16 @@ test_expect_success 'copy detection, cached' '
compare_diff_raw current expected
'
+test_expect_success 'exit code of quiet copy detection' '
+ test_expect_code 1 \
+ git diff --quiet --cached --find-copies-harder $tree
+'
+
+test_expect_success 'exit code of quiet copy detection with --no-ext-diff' '
+ test_expect_code 1 \
+ git diff --quiet --cached --find-copies-harder --no-ext-diff $tree
+'
+
# In the tree, there is only path0/COPYING. In the cache, path0 and
# path1 both have COPYING and the latter is a copy of path0/COPYING.
# However when we say we care only about path1, we should just see
--
2.51.2
next prev parent reply other threads:[~2025-11-09 12:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-08 19:05 diff --cached --no-ext-diff --find-copies-harder --quiet exits with wrong status code D. Ben Knoble
2025-11-08 19:08 ` D. Ben Knoble
2025-11-08 19:12 ` D. Ben Knoble
2025-11-09 12:11 ` René Scharfe [this message]
2025-11-09 14:18 ` [PATCH] diff: disabled quick optimization with --find-copies-harder Phillip Wood
2025-11-09 16:43 ` René Scharfe
2025-11-09 16:43 ` [PATCH v2] diff: disable rename detection with --quiet René Scharfe
2025-11-09 17:34 ` D. Ben Knoble
2025-11-09 18:35 ` René Scharfe
2025-11-10 23:58 ` D. Ben Knoble
2025-11-10 9:42 ` Phillip Wood
2025-11-10 17:54 ` Jeff King
2025-11-10 19:13 ` Junio C Hamano
2025-11-22 21:44 ` René Scharfe
2025-11-23 7:09 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bbd1a371-b0a4-4412-b329-cb4d654a0ca8@web.de \
--to=l.s.r@web$(echo .)de \
--cc=ben.knoble@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=peff@peff$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox