From b55e6d36ebce69136559add8fffd1a65df231518 Mon Sep 17 00:00:00 2001 From: Lidong Yan Date: Fri, 8 Aug 2025 11:30:19 +0800 Subject: diff: ensure consistent diff behavior with ignore options In git-diff, options like `-w` and `-I`, two files are considered equivalent under the specified "ignore" rules, even when they are not bit-for-bit identical. For options like `--raw`, `--name-status`, and `--name-only`, git-diff deliberately compares only the SHA values to determine whether two files are equivalent, for performance reasons. As a result, a file shown in `git diff --name-status` may not appear in `git diff --patch`. To quickly determine whether two files are equivalent, add a helper function diff_flush_patch_quietly() in diff.c. Add `.dry_run` field in `struct diff_options`. When `.dry_run` is true, builtin_diff() returns immediately upon finding any change. Call diff_flush_patch_quietly() to determine if we should flush `--raw`, `--name-only` or `--name-status` output. Signed-off-by: Jeff King Signed-off-by: Lidong Yan Signed-off-by: Junio C Hamano --- diff.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 62e5768a9a..91b3e1c5cf 100644 --- a/diff.h +++ b/diff.h @@ -400,6 +400,8 @@ struct diff_options { #define COLOR_MOVED_WS_ERROR (1<<0) unsigned color_moved_ws_handling; + bool dry_run; + struct repository *repo; struct strmap *additional_path_headers; -- cgit v1.3