Skip to main content

Module diff

Module diff 

Source
Expand description

Embeddable diff facade and report model.

Structs§

ContextSnippet
DiffOptions
Options for computing a diff report through the embeddable facade.
DiffReport
DiffStats
FileChange
FileContextEntry
FileEolState
Trailing-newline state for both sides of a file change, plus the total line count per side. The patch renderer reads these to decide whether to emit \ No newline at end of file and where.
LineCounts
LineDiff
PlainGitDiffProbe
Core-friendly view of the plain-Git probe the CLI health layer discovers.
SemanticChangeEntry
SymlinkChange
The raw symlink target bytes for each side of a symlink change. A symlink’s git blob is exactly its target bytes (no trailing newline), so these are the authoritative content the patch renderer emits. old is None on an add, new is None on a delete, and both are Some on a target-edit or rename-with-edit. The bytes come from the same loaders the hunk path uses (symlink_target_bytes for the worktree, the stored blob for a tree side), so a non-UTF-8 target survives without lossy conversion.

Functions§

change_line_counts
compute_state_diff
Compute a state-to-state diff payload without printing.
compute_tree_diff
Compute a diff from an existing state to an in-memory tree.
diff
Compute a Heddle diff report without rendering to stdout.
diff_worktree_status
Compute a HEAD-vs-worktree report from an existing status scan.
plain_git_head_diff
Compute a HEAD-vs-worktree report for a plain Git repository discovered by the CLI health layer.
render_diff_patch
Lossy String view of the byte-exact patch (render_diff_patch_bytes), for the JSON .patch field and String-based callers/tests. Only a non-UTF-8 symlink target (Unix-only) differs from the byte render; JSON strings cannot carry raw bytes, so a lossy view is the best a String surface can do. The round-trip surface (heddle diff --patch) writes the bytes directly via render_diff_patch_bytes, so its byte fidelity is never reduced here.
render_diff_patch_bytes
should_render_modified_pair
trim_added_decorations_for_display
Pretty-display transform: drop a leading added “decoration” line (#[...], ///, @, etc.) when an identical context line already follows the inserted block, so the diff anchors on the existing item rather than showing a duplicated attribute.
write_diff_patch