{"record":{"id":"99aeaedad2b9306f","repo":"gitbutlerapp/gitbutler","slug":"re-merging-the-conflicting-trees-of-commit-commit","errorCode":null,"errorMessage":"Re-merging the conflicting trees of commit {commit_id} yielded no conflicts to resolve","messagePattern":"Re-merging the conflicting trees of commit (.+?) yielded no conflicts to resolve","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/resolve/context.rs","lineNumber":168,"sourceCode":"    let repo = repo.clone().for_tree_diffing()?;\n    // Merge without favoring a side to reproduce the actual conflicts, and\n    // force diff3-style markers with the sentinel labels so every hunk carries\n    // the common ancestor and marker lines are exactly known strings.\n    let mut options: gix::merge::plumbing::tree::Options = repo.tree_merge_options()?.into();\n    options.blob_merge.text.conflict = gix::merge::blob::builtin_driver::text::Conflict::Keep {\n        style: gix::merge::blob::builtin_driver::text::ConflictStyle::Diff3,\n        marker_size: 7.try_into().expect(\"non-zero constant\"),\n    };\n    let mut outcome = repo.merge_trees(base, ours, theirs, merge_labels(), options.into())?;\n    let merged_tree_id = outcome.tree.write()?.detach();\n\n    let mut index = repo.index_from_tree(&merged_tree_id)?;\n    if !outcome.index_changed_after_applying_conflicts(\n        &mut index,\n        gix::merge::tree::TreatAsUnresolved::git(),\n        gix::merge::tree::apply_index_entries::RemovalMode::Mark,\n    ) {\n        bail!(\n            \"Re-merging the conflicting trees of commit {commit_id} yielded no conflicts to resolve\"\n        );\n    }\n\n    let mut sides_by_path: std::collections::BTreeMap<BString, ConflictSides> = Default::default();\n    for entry in index.entries() {\n        use gix::index::entry::Stage;\n        let sides = sides_by_path\n            .entry(entry.path(&index).to_owned())\n            .or_default();\n        match entry.stage() {\n            Stage::Unconflicted => continue,\n            Stage::Base => sides.base = true,\n            Stage::Ours => sides.ours = true,\n            Stage::Theirs => sides.theirs = true,\n        }\n    }\n    sides_by_path.retain(|_, sides| sides.base || sides.ours || sides.theirs);","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/resolve/context.rs#L150-L186","documentation":"After reconstructing the merged tree, the library re-applies conflicts to the index and expects conflicts to appear. If the index is unchanged, re-merging the two conflicting trees produced no resolvable conflicts — likely the trees are actually mergeable cleanly or the conflicted-state metadata is stale — so building a request would be meaningless.","triggerScenarios":"build_request re-merges base/ours/theirs trees; outcome.index_changed_after_applying_conflicts returns false, meaning the merge succeeded cleanly or yielded no entries the index marks as unresolved.","commonSituations":"The conflict was recorded but both sides are now identical content, a merge tool previously auto-resolved files but the conflicted tree ids were kept, or race where the commit was resolved concurrently.","solutions":["Refresh workspace state — the conflict is likely already resolved","If the commit's trees are genuinely identical, drop the resolution flow and use the merged result","Re-detect conflicts to get updated conflicted commit ids"],"exampleFix":"// before\nbuild_request(repo, stale_commit_id)\n// after\nlet conflicted = detect_conflicts(workspace)?;\nif conflicted.iter().any(|c| c.commit_id == commit_id) { build_request(repo, commit_id) }","handlingStrategy":"validation","validationCode":"const c = await listConflictedCommits(); if (!c.some(x => x.commitId === commitId && x.needsResolution)) throw new Error('nothing to resolve');","typeGuard":null,"tryCatchPattern":"try { await buildRequest(commitId); } catch (e) { if (String(e).includes('yielded no conflicts')) { /* treat as already resolved, skip */ } else { throw e; } }","preventionTips":["Re-detect conflicts before each resolution attempt","Handle the already-resolved race between detection and request building","Treat this error as a signal the conflict is resolved"],"tags":["merge-conflict","invalid-state","re-merge"],"backgroundTag":"invalid-state-transition","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}