{"record":{"id":"63dace1935d1f7b8","repo":"gitbutlerapp/gitbutler","slug":"failed-to-apply-branch-outcome","errorCode":null,"errorMessage":"Failed to apply branch: {outcome}","messagePattern":"Failed to apply branch: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/status/tui/app/stack_mode.rs","lineNumber":406,"sourceCode":"            b.has_local\n                .cmp(&a.has_local)\n                .then_with(|| b.updated_at.cmp(&a.updated_at))\n                .then_with(|| a.name.cmp(&b.name))\n        });\n\n        let Some(items) = NonEmpty::from_vec(branches) else {\n            return Ok(());\n        };\n        let picker = FuzzyPicker::new(items, self.theme, |item, ctx, messages| {\n            let branch = {\n                let repo = ctx.repo.get()?;\n                BranchArg(item.name.clone()).resolve_legacy_top_level_apply_branch_name(&repo)?\n            };\n\n            let mut guard = ctx.exclusive_worktree_access();\n            match apply::run(ctx, guard.write_permission(), ApplyOperation { branch })? {\n                ApplyOutcome::ConflictAborted(outcome) => {\n                    anyhow::bail!(\"Failed to apply branch: {outcome}\")\n                }\n                ApplyOutcome::AlreadyApplied { .. } | ApplyOutcome::Applied { .. } => {}\n            }\n\n            messages.extend([\n                Message::EnterNormalModeAfterConfirmingOperation,\n                Message::Reload(\n                    Some(SelectAfterReload::Branch(item.name)),\n                    ReloadCause::Mutation,\n                ),\n            ]);\n\n            Ok(())\n        });\n        self.modal = Some(Modal::ApplyStackPicker {\n            picker: Box::new(picker),\n            key_binds: fuzzy_picker_key_binds(),\n        });","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/status/tui/app/stack_mode.rs#L388-L424","documentation":"In the status TUI's stack-mode apply flow (crates/but/src/command/legacy/status/tui/app/stack_mode.rs:406), apply::run returning ApplyOutcome::ConflictAborted(outcome) is converted to a hard error. The abort means applying the selected branch onto the current workspace would produce merge conflicts, so the operation was rolled back without touching the worktree; the outcome detail lists what conflicted.","triggerScenarios":"Applying a branch via the stack-mode fuzzy picker when its changes conflict with already-applied workspace branches — overlapping edits to the same files or hunks.","commonSituations":"Two stacks editing the same lines; applying a branch forked before recent workspace changes; stale branches that need rebasing onto the target.","solutions":["Read the conflict detail in the outcome message to identify the clashing files, then unapply the conflicting stack and apply branches in an order that avoids the overlap.","Update/rebase the branch onto the current target so it applies cleanly, then retry.","Move the conflicting commits to a separate stack or apply the branch in a dedicated worktree."],"exampleFix":"# before: stacks 'auth' and 'db' both edit schema.sql\n# stack-mode -> apply 'db'  ->  Failed to apply branch: conflict...\n\n# after\nbut branch unapply auth   # or move conflicting commits\n# then apply 'db', then re-apply 'auth' resolving order","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match apply::run(ctx, guard.write_permission(), ApplyOperation { branch })? {\n    ApplyOutcome::ConflictAborted(outcome) => {\n        // surface outcome (conflicting files), suggest unapply/reorder, keep worktree untouched\n        Err(anyhow::anyhow!(\"Failed to apply branch: {outcome}\"))\n    }\n    ApplyOutcome::AlreadyApplied { .. } | ApplyOutcome::Applied { .. } => Ok(()),\n}","preventionTips":["Apply branches touching disjoint files, or unapply conflicting stacks first.","Rebase/update branches onto the current target before applying.","Treat ConflictAborted as a clean rollback: the worktree is unchanged, so retry after reordering is safe."],"tags":["tui","apply","conflict","merge","workspace"],"backgroundTag":"merge-conflict","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}