Skip to main content

merge_scope

Function merge_scope 

Source
pub fn merge_scope(dir: &Path) -> Result<Option<MergeScope>, Box<dyn Error>>
Expand description

Find the merge/rebase this repository is in — or has just finished — and read it.

Three shapes, in order, because they are the moments an agent asks:

  • mid-merge: MERGE_HEAD exists. Ours is HEAD, theirs is MERGE_HEAD. This is the state right after git merge exits 1, and it survives git add — which is exactly why the index’s unmerged list alone is not enough to find the subjects.
  • mid-rebase / cherry-pick / revert: there is no MERGE_HEAD, but git records the commit being applied as REBASE_HEAD / CHERRY_PICK_HEAD / REVERT_HEAD. Ours is HEAD (the side built so far), theirs is that commit. Without this, weave check fell through to “nothing was checked” during every rebase, while still suggesting itself (issue #157). For a rebase or cherry-pick the base is that commit’s parent (REBASE_HEAD^), not merge-base(ours, theirs): a replay applies one commit as a patch, and the merge base would smear the whole branch’s divergence into it.
  • just committed: HEAD has two parents. Ours is HEAD^1, theirs is HEAD^2. An agent that committed and then wants to know what it did.

No shape present is not an error and must not be reported as one — it is the sentence “there is no merge here”, which the caller prints.