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_HEADexists. Ours isHEAD, theirs isMERGE_HEAD. This is the state right aftergit mergeexits 1, and it survivesgit 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 asREBASE_HEAD/CHERRY_PICK_HEAD/REVERT_HEAD. Ours isHEAD(the side built so far), theirs is that commit. Without this,weave checkfell 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^), notmerge-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:
HEADhas two parents. Ours isHEAD^1, theirs isHEAD^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.