feat(merge): conflict regions + diff3 marker rendering #46

merged colechristensen cole.christensen@gmail.com wants to merge feat/diff3-conflict-regions into main

Part of fangorn/anvil#336 (PR merge-conflict visualization rework) — this is the ex_git_objectstore primitive the anvil consumer PR depends on.

What

Diff3 could only report a whole-file :conflict flag. Its walk/8 already resolves each region between stable anchors and knows each region’s real line offset in base/ours/theirs — it just discarded that on conflict. Two functions reuse the same anchor analysis:

  • conflict_regions/3 — returns each conflicting region localized to its true per-side line offsets (base_start/ours_start/theirs_start) plus that side’s lines. This is what a conflict visualization needs (localized hunks, not three whole files).
  • merge_markers/4 — renders a diff3 conflict-marker file (a ready-to-edit seed for manual resolution). Clean regions reproduce merge/3 byte-exact.

Both derive from a shared segments/3 walk; the verified merge/3 path is unchanged.

Verification

24 merge unit tests + the git merge-file differential fuzz pass; mix format + mix credo --strict clean.

Created Jul 10, 2026 at 07:36 UTC | Merged Jul 10, 2026 at 14:37 UTC by colechristensen cole.christensen@gmail.com