From: Phillip Wood Date: Sun, 09 Nov 2025 14:18:39 GMT Subject: Re: [PATCH] diff: disabled quick optimization with --find-copies-harder Message-ID: <40a322a6-7fd7-4003-a23f-7672a36b5bf2@gmail.com> In-Reply-To: On 09/11/2025 12:11, René Scharfe wrote: > 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. Stepping back a bit I'm confused as to why we don't disable rename and copy detection when "--quiet" is given. I can't see why detecting copies or renames would change the exit code but maybe I'm missing something. Thanks Phillip > 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 > Signed-off-by: René Scharfe > --- > 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