{"record":{"id":"244f4feebc1445ce","repo":"gitbutlerapp/gitbutler","slug":"commit-commit-ref-is-not-in-a-conflicted-state","errorCode":null,"errorMessage":"Commit {commit_ref} is not in a conflicted state. Only conflicted commits can be resolved.","messagePattern":"Commit (.+?) is not in a conflicted state\\. Only conflicted commits can be resolved\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":207,"sourceCode":"        }\n        _ => bail!(\"'{commit_id_str}' does not refer to a commit\"),\n    }\n}\n\nfn enter_resolution(ctx: &mut Context, out: &mut OutputChannel, commit_id_str: &str) -> Result<()> {\n    let t = theme::get();\n    use gix::{prelude::ObjectIdExt as _, revision::walk::Sorting};\n\n    let (commit_gix_oid, commit_ref) = parse_commit_id(ctx, commit_id_str)?;\n\n    // Get the commit and check if it's conflicted\n    let repo = ctx.repo.get()?;\n    let commit = repo\n        .find_commit(commit_gix_oid)\n        .context(\"Failed to find commit\")?;\n\n    if !commit.is_conflicted() {\n        bail!(\n            \"Commit {commit_ref} is not in a conflicted state. Only conflicted commits can be resolved.\"\n        );\n    }\n\n    // Find which stack this commit belongs to\n    let stacks = crate::legacy::workspace::applied_stacks(ctx)?;\n    let mut found_stack_id = None;\n    'outer: for stack in &stacks {\n        // Check if this commit is in any of the stack's heads\n        // TODO(ctx): use `ws` for that.\n        // TODO(perf): This is likely to walk the whole graph.\n        for head in &stack.branches {\n            // Walk the commit history to see if our commit is in this stack\n            let traversal = head\n                .tip\n                .attach(&repo)\n                .ancestors()\n                .sorting(Sorting::BreadthFirst)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L189-L225","documentation":"State validation in enter_resolution: the resolved commit exists but is not marked conflicted, and only conflicted commits can enter the resolution flow. The caller should verify with 'but status' which commits actually carry conflicts.","triggerScenarios":"`but resolve <commit-id>` (or check_and_prompt_for_conflicts flow) on a commit whose merge state has no conflicts — e.g. already resolved, or a normal clean commit.","commonSituations":"Re-running resolve on a commit already finished; picking the wrong stack commit from `but status`; conflicts auto-resolved upstream before the command ran.","solutions":["Run `but status` and confirm the commit shows as conflicted","If already resolved, no action is needed — skip `but resolve <commit>`","Choose the correct conflicted commit ID from the status output"],"exampleFix":"// before\nbut resolve 9f2c1ab   # clean commit\n// after\nbut status            # identify conflicted commit\nbut resolve <conflicted-id>","handlingStrategy":"validation","validationCode":"if !commit_is_conflicted(commit_id) { eprintln!(\"{commit_id} is not conflicted; nothing to resolve\"); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = enter_resolution(ctx, out, id) {\n    if e.to_string().contains(\"not in a conflicted state\") {\n        eprintln!(\"Skip resolution; select a conflicted commit from 'but status'\");\n    }\n}","preventionTips":["Verify conflict markers/state with `but status` before resolving","Skip already-resolved commits in automation","Re-check commit state after rebases or upstream syncs"],"tags":["cli","conflict","precondition"],"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"}