diff.c: decouple white space treatment from move detection algorithm
commitb3095712f9d81572c3658d579e50db907b72f46d
authorStefan Beller <sbeller@google.com>
Mon, 16 Jul 2018 23:05:40 +0000 (16 16:05 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 17 Jul 2018 18:25:31 +0000 (17 11:25 -0700)
tree72c68e3d2d5f55500021cd15254a3ca7e73dd1df
parent51da15eb2301667c6ac01dd18851b7a424fbf2b1
diff.c: decouple white space treatment from move detection algorithm

In the original implementation of the move detection logic the choice for
ignoring white space changes is the same for the move detection as it is
for the regular diff.  Some cases came up where different treatment would
have been nice.

Allow the user to specify that white space should be ignored differently
during detection of moved lines than during generation of added and removed
lines. This is done by providing analogs to the --ignore-space-at-eol,
-b, and -w options by introducing the option --color-moved-ws=<modes>
with the modes named "ignore-space-at-eol", "ignore-space-change" and
"ignore-all-space", which is used only during the move detection phase.

As we change the default, we'll adjust the tests.

For now we do not infer any options to treat white spaces in the move
detection from the generic white space options given to diff.
This can be tuned later to reasonable default.

As we plan on adding more white space related options in a later patch,
that interferes with the current white space options, use a flag field
and clamp it down to  XDF_WHITESPACE_FLAGS, as that (a) allows to easily
check at parse time if we give invalid combinations and (b) can reuse
parts of this patch.

By having the white space treatment in its own option, we'll also
make it easier for a later patch to have an config option for
spaces in the move detection.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/diff-options.txt
diff.c
diff.h
t/t4015-diff-whitespace.sh