FA-75764 / Text diff and three-way merge / Member archive
Unified hunk parser: the body stops when either side is exhausted · case 04
Hunks ending in additions or removals are reported as truncated.
Case contract
Parse "@@ -a[,b] +c[,d] @@" hunks (omitted counts are 1) and consume body lines until both remaining counts reach zero: " " (or a completely empty line) counts for both sides, "-" for old, "+" for new, "\\" marker lines are skipped and not counted, anything else ends the body. Remaining counts other than zero yield {"error": "hunk k truncated"}. Return [a, b, c, d, body_lines] per hunk.
Why this case matters
Patch tools must validate hunk bodies against their headers before applying anything.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| omitted counts mean one | {"error": "hunk 0 truncated"} | {"hunks": [[4, 1, 4, 1, 2]]} | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗