{"record":{"id":"a178a70bf973480e","repo":"jdx/mise","slug":"multiple-merge-bases-require-explicit-git-reconcil","errorCode":null,"errorMessage":"multiple merge bases require explicit Git reconciliation before applying enrollment","messagePattern":"multiple merge bases require explicit Git reconciliation before applying enrollment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/run.rs","lineNumber":1005,"sourceCode":"pub(super) fn incoming_tracking(\n    repo: &crate::system::history::shadow::HistoryRepo,\n    tracked: &TrackedSet,\n) -> Result<TrackedSet> {\n    use crate::system::history::manifest::Manifest;\n    let heads = super::graph::Heads::read(repo)?;\n    let Some(remote) = &heads.remote else {\n        return Ok(tracked.clone());\n    };\n    let remote = Manifest::read(repo, remote)?\n        .ok_or_else(|| eyre::eyre!(\"setup repository has no enrollment metadata\"))?;\n    let manifest = match (&heads.local, &heads.base) {\n        (None, _) => remote,\n        (Some(local), Some(base)) => Manifest::merge(\n            &Manifest::read(repo, base)?.unwrap_or_default(),\n            &Manifest::read(repo, local)?.unwrap_or_default(),\n            &remote,\n        )?,\n        (Some(_), None) => bail!(\n            \"multiple merge bases require explicit Git reconciliation before applying enrollment\"\n        ),\n    };\n    let mut incoming = manifest.tracking()?;\n    incoming.required_sources = tracked.required_sources.clone();\n    incoming.invalid = tracked.invalid.clone();\n    Ok(incoming)\n}\n\n/// Complete-tree changes outside active native files still need adoption:\n/// enrollment, inactive variants, and ordinary repository documentation.\npub(super) fn incoming_repository_tree(\n    repo: &crate::system::history::shadow::HistoryRepo,\n    tracked: &TrackedSet,\n) -> Result<Option<String>> {\n    let heads = super::graph::Heads::read(repo)?;\n    let (Some(local), Some(remote)) = (&heads.local, &heads.remote) else {\n        return Ok(None);","sourceCodeStart":987,"sourceCodeEnd":1023,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/sync/run.rs#L987-L1023","documentation":"When building the incoming tracking manifest, mise merges the remote manifest with the local one using a merge base. If there is a local head but no merge base (disjoint histories), a three-way merge is impossible to do safely at the manifest level, so mise requires the user to reconcile the histories in Git explicitly before enrollment is applied.","triggerScenarios":"`mise dot sync`/prepare reaching incoming_tracking with (Some(local_head), None merge base) — i.e. the local history and the incoming upstream history share no common ancestor (unrelated histories).","commonSituations":"The upstream repository's history was rewritten or replaced wholesale (force-push of an unrelated root); the local repository was re-initialized with a fresh history; pointing mise at a repo cloned independently with different roots.","solutions":["Reconcile the histories in Git explicitly: merge the upstream branch with `--allow-unrelated-histories` (resolving conflicts), then re-run sync.","If the local history is disposable, re-initialize/re-clone from the origin so both sides share history, then sync.","If upstream was rewritten intentionally, reset local sync state to the new upstream (re-connect origin / pull fresh) before syncing."],"exampleFix":"// before: unrelated histories block manifest merge\nmise dot sync // error: multiple merge bases require explicit Git reconciliation\n// after: reconcile in Git first\ngit fetch origin\ngit merge origin/<branch> --allow-unrelated-histories  # resolve conflicts\nmise dot sync","handlingStrategy":"fallback","validationCode":"// detect a missing merge base before syncing\nlet base = repo.merge_base(local_head, upstream_head)?;\nif base.is_none() {\n    eprintln!(\"reconcile histories in git first (--allow-unrelated-histories)\");\n    return;\n}","typeGuard":"fn mergeable(local: Option<Oid>, base: Option<Oid>) -> bool {\n    match (local, base) { (Some(_), None) => false, _ => true }\n}","tryCatchPattern":"match sync() {\n    Err(e) if e.to_string().contains(\"multiple merge bases require explicit Git reconciliation\") => eprintln!(\"git merge --allow-unrelated-histories origin/<branch>, then retry\"),\n    other => other,\n}","preventionTips":["Never force-push a brand-new history to the shared setup branch.","Initialize local sync state by cloning/pulling from origin rather than re-initializing history.","Before pointing mise at a repo, verify it shares history with your existing sync state."],"tags":["git","sync","merge-base","unrelated-histories"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}