Expand description
Replay: the unified-diff parser of subsumption (replay_patch).
What:
The unified-diff parser that replay’s subsumption reads:
git diff-tree -p output over single-level trees named by decimal index,
split into hunks per entry name.
Why:
Subsumption decides from hunk lines and their markers;
the parser keeps every byte exact,
so a hunk line round-trips to the blob bytes it came from.
In TS you’d write (pseudocode):
parseIndexedPatch(text: string): ReadonlyMap<string, readonly PatchHunk[]>Structs§
- Patch
Hunk - What:
One unified-diff hunk:
its first old and new line and its lines in order.
Why:
A zero-based start is derived from
oldStartby the callers that need it. - Patch
Line - What:
One patch line:
its marker (
b' ',b'-',b'+') and its bytes. Why: The reverse check and the containment check both read the markers. - Replay
Patch Format Error - What:
Patch output that does not have the shape
git diff-tree -pwrites. Why: Callers fail the replay rather than guess at a truncated or foreign patch.
Functions§
- parse_
indexed_ patch - What:
Parse
git diff-tree -poutput over index-named single-level trees into hunks per entry name; an entry without a section has no change. Why: Subsumption reads each candidate’s landed and prepared hunks by its index name, so no patch header carries a user path. - split_
keeping_ newlines - What:
Split bytes into lines,
each keeping its newline;
an unterminated last line stays as it is.
Why:
Hunk bodies and blob contents are compared line by line,
newline included, the way Git’s
xdiffcompares them.