The coloring of moved lines is currently only related to the presentation,
as there are no options to export the move detection information into
the patch format. Hence we can be very loose about the default, so let's
ignore any white space change for the move detection. If a user really
cares about move detection detecting only lines moved byte-for-byte,
they can exercise the --color-moved-no-ignore-* options.

Signed-off-by: Stefan Beller <sbel...@google.com>
---
 Documentation/diff-options.txt | 4 +++-
 diff.c                         | 1 +
 t/t4015-diff-whitespace.sh     | 6 ++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 1000b53b84..fdf40cbefc 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -269,14 +269,16 @@ dimmed_zebra::
        Ignore whitespace when comparing lines when performing the move
        detection for --color-moved.  This ignores differences even if
        one line has whitespace where the other line has none.
+       This is on by default.
 --color-moved-[no-]ignore-space-change::
        Ignore changes in amount of whitespace when performing the move
        detection for --color-moved.  This ignores whitespace
        at line end, and considers all other sequences of one or
        more whitespace characters to be equivalent.
+       This is on by default.
 --color-moved-[no-]ignore-space-at-eol::
        Ignore changes in whitespace at EOL when performing the move
-       detection for --color-moved.
+       detection for --color-moved. This is on by default.
 
 --word-diff[=<mode>]::
        Show a word diff, using the <mode> to delimit changed words.
diff --git a/diff.c b/diff.c
index 2580315ab9..fef4874169 100644
--- a/diff.c
+++ b/diff.c
@@ -4105,6 +4105,7 @@ void diff_setup(struct diff_options *options)
        }
 
        options->color_moved = diff_color_moved_default;
+       options->color_moved_ignore_space = XDF_WHITESPACE_FLAGS;
 }
 
 void diff_setup_done(struct diff_options *options)
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 4ef4d6934a..a4ffc84f41 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -1813,6 +1813,12 @@ test_expect_success 'move detection only ignores white 
spaces' '
         Qbar();<RESET>
         Q// more unrelated stuff<RESET>
        EOF
+       test_cmp expected actual &&
+
+       # test that this is the default:
+       git diff --color --color-moved |
+               grep -v "index" |
+               test_decode_color >actual &&
        test_cmp expected actual
 '
 
-- 
2.15.0.rc2.6.g953226eb5f

Reply via email to