Skip to main content

Module diff_moved

Module diff_moved 

Source
Expand description

Move detection for git diff --color-moved, implementing the same behavior as git’s add_lines_to_move_detection + mark_color_as_moved + dim_moved_lines.

Operates on the already-rendered plain unified diff text (one or more files of diff --git headers, @@ hunk headers, and +/-/context body lines). It identifies blocks of moved code and returns, for every line of the input patch, a MovedClass telling the colorizer which color slot to use.

Enums§

ColorMovedMode
--color-moved mode.
MovedClass
The color class assigned to one emitted line after move detection.

Constants§

MOVED_WS_ALLOW_INDENTATION_CHANGE
MOVED_WS_ERROR
MOVED_WS_IGNORE_ALL_SPACE
MOVED_WS_IGNORE_SPACE_AT_EOL
MOVED_WS_IGNORE_SPACE_CHANGE

Functions§

detect_moved_lines
Run move detection over a plain multi-file unified diff. Returns a vector parallel to the patch’s lines (patch.split_inclusive('\n')) giving each line’s MovedClass; non-+/- lines are always MovedClass::None.
parse_color_moved_ws
Parse a comma-separated --color-moved-ws=<modes> value into the bit flags. Sets MOVED_WS_ERROR for unknown modes or the illegal allow-indentation-change + other-ws combination (git errors out then).