{"record":{"id":"6dd9fbacbf04327b","repo":"gitbutlerapp/gitbutler","slug":"squash-step-must-have-at-least-two-commits","errorCode":null,"errorMessage":"Squash step must have at least two commits","messagePattern":"Squash step must have at least two commits","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-workspace/src/branch/integrate_branch_upstream/plan.rs","lineNumber":257,"sourceCode":"            bail_precondition!(\n                \"Integration plan is invalid: prepared commit {commit_id} appears more than once\"\n            );\n        }\n        prepared.push(step);\n    }\n\n    Ok(prepared)\n}\n\n/// Precompute the squash payload from the current editor/repository state,\n/// before later integration graph mutations can rewire step-graph ancestry.\nfn prepare_squash_step_for_editor<M: RefMetadata>(\n    editor: &Editor<'_, '_, M>,\n    commit_ids: &[gix::ObjectId],\n    message: Option<&str>,\n) -> Result<gix::ObjectId> {\n    if commit_ids.len() < 2 {\n        bail!(\"Squash step must have at least two commits\");\n    }\n\n    let maybe_selectors = commit_ids\n        .iter()\n        .map(|commit_id| editor.try_select_commit(*commit_id))\n        .collect::<Vec<_>>();\n    let ordered_commit_ids = if maybe_selectors.iter().all(Option::is_some) {\n        let ordered_selectors = editor.order_commit_selectors_by_parentage(\n            maybe_selectors\n                .into_iter()\n                .map(|selector| selector.expect(\"checked all selectors are present\"))\n                .collect::<Vec<_>>(),\n        )?;\n        ordered_selectors\n            .iter()\n            .map(|selector| {\n                editor\n                    .find_selectable_commit(*selector)","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-workspace/src/branch/integrate_branch_upstream/plan.rs#L239-L275","documentation":"prepare_squash_step_for_editor only supports squashing two or more commits; a squash step with fewer than two commit IDs is rejected before any editor selectors are built. A single commit has nothing to squash into, so the operation is meaningless.","triggerScenarios":"Constructing a PreparedIntegrationStep::Pick/squash step whose commit_ids slice has 0 or 1 entries and passing it through prepare_squash_step_for_editor.","commonSituations":"Upstream integration logic collapsing a branch that resolved to a single commit, or plan construction filtering commits down to one and still emitting a squash step.","solutions":["Ensure the squash step contains at least two commit IDs before building it, or downgrade a single commit to a plain pick step","Filter out squash steps with <2 commits during plan preparation","If the intent was to reword a single commit, use the commit/pick path instead of squash"],"exampleFix":"// before\nsteps.push(Step::Squash(vec![commit_id]));\n// after\nif commits.len() >= 2 {\n    steps.push(Step::Squash(commits));\n} else {\n    steps.push(Step::Pick(commits[0]));\n}","handlingStrategy":"validation","validationCode":"fn can_squash(commit_ids: &[gix::ObjectId]) -> bool {\n    commit_ids.len() >= 2\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"Squash step must have at least two commits\") => {\n        // fall back to a plain pick of the single commit\n        pick_single_commit(commit_ids[0])?;\n        Ok(())\n    }\n    other => other,\n}","preventionTips":["Check commit_ids.len() >= 2 before emitting a squash step","Downgrade singleton squash steps to pick steps in plan construction","Log plan steps during upstream integration to catch degenerate squashes early"],"tags":["git","rebase","squash"],"backgroundTag":"invalid-argument-value","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"}