FAILURE MAP
← Case archive

FA-75423 / Text diff and three-way merge / Member archive

Patch application with offset search: equal distances prefer the later position · case 03

An ambiguous hunk applies to the later of two equally distant matches.

Member previewVariant 3 · 3 implementations · 11 checks per implementation

Case contract

Hunks [old_start, old_lines, new_lines] are applied in order. The expected index is old_start-1 plus the accumulated shift. The search tries distance 0, then 1, 2, ... up to max_offset, at each distance the earlier position before the later one; the first position where old_lines match replaces them with new_lines. After an applied hunk the shift grows by (found-expected) + len(new)-len(old); a hunk that does not match is rejected and changes nothing. Return lines, 1-based applied positions and rejected hunk indices.

Why this case matters

Patch tools tolerate drift by searching near the expected line and carrying the discovered offset to later hunks.

One recorded failure

Sample boundary fixture

This sample comes from the broken implementation of a controlled reproducer.

Boundary fixtureActualExpectedOutcome
equal distances prefer the earlier match{"applied": [4], "lines": ["a", "k", "b", "K", "c"], "rejected": []}{"applied": [2], "lines": ["a", "K", "b", "k", "c"], "rejected": []}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 ↗