Expand description
Typed model of git conflict markers — parse a conflicted file’s content into structured regions and write a chosen resolution back. Pure functions (no subprocess), so everything here is hermetic.
Handles git’s three merge.conflictStyles with one grammar: merge
(2-way: ours/theirs), diff3 (3-way: ours/base/theirs), and zdiff3
(same markers as diff3 — the common affixes are already outside the
region). Marker length is variable (merge.conflictMarkerSize, default 7)
and is detected per region. Lines are kept verbatim (including \r\n and
a missing trailing newline), so render is a byte-exact roundtrip.
jj note: files materialized with jj’s ui.conflict-marker-style = "git"
use this exact grammar (with jj’s own labels) and parse here; jj’s native
diff/snapshot styles live in vcs_jj::conflict.
Structs§
- Conflict
Region - One conflicted region: the lines of each side plus the verbatim marker lines (kept so rendering is byte-exact).
Enums§
- Conflict
Segment - A conflicted file as a sequence of plain-text runs and conflict regions —
the shape that keeps
rendera byte-exact roundtrip. - Resolution
Side - Which side of a conflict a resolution keeps.
Functions§
- has_
conflict_ markers - Does
contentcontain a line that looks like a conflict-start marker? Cheap pre-check before a fullparse_conflicts. - parse_
conflicts - Parse a conflicted file’s content into text/conflict segments.
- render
- Re-render segments verbatim — the byte-exact inverse of
parse_conflicts. - resolve
- Produce the file content with every conflict resolved to
side.