]> git.ipfire.org Git - thirdparty/git.git/commit - diff.c
diff --color-moved-ws: modify allow-indentation-change
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 23 Nov 2018 11:16:57 +0000 (11:16 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Jan 2019 18:38:24 +0000 (10:38 -0800)
commit21536d077f4b7b8a249f1fc894dafc38f06cef0f
tree562ce46adb19831aa91a0cf6243281ca62b2c2e1
parent7a4252c4df49fe07bf91dbb5be2c6012f6a65329
diff --color-moved-ws: modify allow-indentation-change

Currently diff --color-moved-ws=allow-indentation-change does not
support indentation that contains a mix of tabs and spaces. For
example in commit 546f70f377 ("convert.h: drop 'extern' from function
declaration", 2018-06-30) the function parameters in the following
lines are not colored as moved [1].

-extern int stream_filter(struct stream_filter *,
-                        const char *input, size_t *isize_p,
-                        char *output, size_t *osize_p);
+int stream_filter(struct stream_filter *,
+                 const char *input, size_t *isize_p,
+                 char *output, size_t *osize_p);

This commit changes the way the indentation is handled to track the
visual size of the indentation rather than the characters in the
indentation. This has the benefit that any whitespace errors do not
interfer with the move detection (the whitespace errors will still be
highlighted according to --ws-error-highlight). During the discussion
of this feature there were concerns about the correct detection of
indentation for python. However those concerns apply whether or not
we're detecting moved lines so no attempt is made to determine if the
indentation is 'pythonic'.

[1] Note that before the commit to fix the erroneous coloring of moved
    lines each line was colored as a different block, since that commit
    they are uncolored.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4015-diff-whitespace.sh