Skip to main content

materialize_conflicts

Function materialize_conflicts 

Source
pub fn materialize_conflicts(
    root: &Path,
    store: &ObjectStore,
    merged_tree: Hash,
    conflicts: &[Conflict],
) -> Result<Vec<ConflictRecord>, String>
Expand description

Materialise every conflict into the worktree and stage the ours-side blob into the index so each conflicting path is “resolvable”:

  • text: write <<<<<<< ours / ======= / >>>>>>> theirs markers.
  • binary / special / delete-modify: leave the surviving content in the worktree, print a per-path manual-resolution note.

The index entry for each path is set to the ours-side blob (or removed for an ours-deleted delete/modify) so a subsequent mkit add after resolution updates it normally and --continue builds the tree from the resolved index/worktree.

merged_tree is the operation’s full merge-result tree (holding “ours” at every conflicted path and the clean changes everywhere else). It is applied to the index + worktree FIRST — otherwise the non-conflicting changes would never reach the index and --continue (which builds from the index) would silently drop them (#269). The caller runs super::ensure_restore_safe over merged_tree first, so this never clobbers dirty tracked or untracked content. Conflict markers are then overlaid on the conflicted paths.

Returns the per-path ConflictRecords for the sidecar.

§Errors

Propagates store / filesystem failures as a message string.