Skip to main content

Module snapshot

Module snapshot 

Source
Expand description

Commit-boundary file snapshots and the pure line diff over them — what lets the generated page re-diff any contiguous commit sub-range without touching git: the CLI collects contents once, the page (via WASM) calls range_diff with a pair of boundary indices.

Nothing here shells out; snapshots arrive as data. Renames are not re-detected inside a sub-range — a rename shows as a delete plus an add.

Structs§

Boundary
The tracked files’ state at one commit boundary.
RangeSnapshots
File contents pinned at every commit boundary of the diffed range, deduplicated by git blob id. Only paths touched by some commit in the range are tracked.

Functions§

context_slice
Unchanged lines shared by a file’s two endpoint snapshots — what the page’s expand-context control reveals inside hunk gaps. Returns up to count Line::Ctx rows starting at old_start/new_start (1-based, pre- and post-image), clamped at either file’s end. The requested region must be text-identical at both endpoints — a gap between hunks always is — so expansion can never invent or hide a change; a mismatch is rejected loudly. old_path/new_path may differ (renamed files).
diff_lines
Diff two texts line-wise into hunks with context unchanged lines around each change — the same Hunk/Line shapes parse_unified_diff produces. Identical texts yield no hunks.
range_diff
The diff between boundaries from and to (from < to, indices into boundaries), as the same FileDiff shape the build-time parser emits. Selecting commit k alone is range_diff(snap, k - 1, k, …).