Skip to main content

Module structured

Module structured 

Source
Expand description

Structured line diffs for CLI and embedders (grit diff, grit show).

Preserves line-ending details (CRLF vs LF, missing newline at EOF), mode-only changes, hunk line counts, and optional UTF-8 lossy decoding markers — without relying on unified patch text parsing.

Structs§

SideBytes
Bytes of one file side prepared for diffing.
StructuredFileDiff
File metadata plus a structured line diff.
StructuredHunk
A contiguous run of changes plus surrounding context.
StructuredLine
One rendered line in a structured hunk.
StructuredSegment
One run of text within a line, with optional intra-line emphasis.
StructuredTextDiff
Line-level diff of two text sides (no file metadata).

Enums§

StructuredLineKind
Kind of line in a structured hunk.

Functions§

format_hunk_range
Format one unified hunk range side (1, 1,2, or 0,0).
structured_file_diff
Build a structured file diff including mode metadata from a tree diff entry.
structured_text_diff
Build a structured line diff from two decoded text sides.