Expand description
The publish-time invariant: a merge keeps each side’s changes.
The gate (crate::land) judges the files BOTH sides changed. A file only
one side changed has nothing to resolve, so the gate never reads it — and
a merge whose tree is not git’s merge (a half-applied merge, a merge git
could not write to the index, a hand-made tree) can silently put such a
file back to the merge base. This module checks the tree itself, however
it was produced, over EVERY path in base→ours ∪ base→theirs:
- a path only theirs changed must hold theirs’ version, or a version that still contains theirs’ change (every token theirs added is there, no token theirs deleted is back; the gate’s DROPPED / UNDELETED measure, the whole file read as one block). A deletion by theirs must stay deleted; a file theirs changed must not be deleted;
- a path only ours changed may be edited further by the merge (the merge commit is ours’ own work), but must not go back to base: not restored to the base version, not deleted when ours changed it, not brought back when ours deleted it.
Paths both sides changed are the gate’s. Any violation refuses, the file named.
Structs§
- Violation
- A path whose change by one side the merge does not keep.
Functions§
- check
- Check the merge
result(any tree-ish) ofoursandtheirsoverbase. Empty = every one-sided change is kept. - check_
now check, keeping only the violations that hold atnowtoo (the branch as it is now: a later commit that put the change back counts).- contains_
change - Whether
mergedstill holds the changebase → side, in tokens: every token the side added is there at least as often as the side has it, and no token the side deleted is there more often than the side has it.None= held;Some(why)= not. - index_
tree - The tree the index would commit, read without touching the index or its lock (a scratch copy of the index).
- merge_
in_ tree - The tree the merge in progress in
dirwould commit, once nothing is left unmerged;Nonewhen no merge is in progress or a path is still unmerged. - render
- The violations as lines for a person:
path (side's change lost: …).