]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: add option to skip resolving diff statuses
authorJustin Tobler <jltobler@gmail.com>
Fri, 28 Feb 2025 21:33:44 +0000 (15:33 -0600)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Mar 2025 16:17:47 +0000 (08:17 -0800)
By default, `diffcore_std()` resolves the statuses for queued diff file
pairs by calling `diff_resolve_rename_copy()`. If status information is
already manually set, invoking `diffcore_std()` may change the status
value.

Introduce the `skip_resolving_statuses` diff option that prevents
`diffcore_std()` from resolving file pair statuses when enabled.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diff.h

diff --git a/diff.c b/diff.c
index 4ddfe523fe9b36fb4ef998f2bb3efc80d0a09bb5..08f5e00a2cc92161c8d96eed2b1fb6de77788022 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -7085,7 +7085,7 @@ void diffcore_std(struct diff_options *options)
                diffcore_order(options->orderfile);
        if (options->rotate_to)
                diffcore_rotate(options);
-       if (!options->found_follow)
+       if (!options->found_follow && !options->skip_resolving_statuses)
                /* See try_to_follow_renames() in tree-diff.c */
                diff_resolve_rename_copy();
        diffcore_apply_filter(options);
diff --git a/diff.h b/diff.h
index 63afa17e84a1f784f74ac08b9c1d4f33ace1f0da..fc791ee2ccb373406ea9f6348d99d8ced1a2d856 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -353,6 +353,14 @@ struct diff_options {
        /* to support internal diff recursion by --follow hack*/
        int found_follow;
 
+       /*
+        * By default, diffcore_std() resolves the statuses for queued diff file
+        * pairs by calling diff_resolve_rename_copy(). If status information
+        * has already been manually set, this option prevents diffcore_std()
+        * from resetting statuses.
+        */
+       int skip_resolving_statuses;
+
        /* Callback which allows tweaking the options in diff_setup_done(). */
        void (*set_default)(struct diff_options *);