From fa052367ef8f7829996ff15368d63edfff0e40c3 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Sun, 9 Nov 2025 17:43:36 +0100 Subject: diff: disable rename detection with --quiet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detecting renames and copies improves diff's output. This effort is wasted if we don't show any. Disable detection in that case. This actually fixes the error code when using the options --cached, --find-copies-harder, --no-ext-diff and --quiet together: run_diff_index() indirectly calls diff-lib.c::show_modified(), which queues even non-modified entries using diff_change() because we need them for copy detection. diff_change() sets flags.has_changes, though, which causes diff_can_quit_early() to declare we're done after seeing only the very first entry -- way too soon. Using --cached, --find-copies-harder and --quiet together without --no-ext-diff was not affected even before, as it causes the flag flags.diff_from_contents to be set, which disables the optimization in a different way. Reported-by: D. Ben Knoble Suggested-by: Phillip Wood Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- diff.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 90e8003dd1..e4f8c0dc6c 100644 --- a/diff.c +++ b/diff.c @@ -4965,6 +4965,8 @@ void diff_setup_done(struct diff_options *options) if (options->flags.quick) { options->output_format = DIFF_FORMAT_NO_OUTPUT; options->flags.exit_with_status = 1; + options->detect_rename = 0; + options->flags.find_copies_harder = 0; } /* -- cgit v1.3