{"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":438,"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":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/status/tui/app/stack_mode.rs#L420-L456","documentation":"When confirming the apply operation from the TUI stack show picker, the legacy apply command is run for the selected branch. If the apply ends with ApplyOutcome::ConflictAborted, the handler bails with a message describing the conflict outcome instead of proceeding. It signals that the branch could not be applied because applying produced conflicts that the user aborted.","triggerScenarios":"Selecting a branch in the stack-show apply picker whose application onto the target base produces merge conflicts and the conflict resolution was aborted (ApplyOutcome::ConflictAborted).","commonSituations":"Applying a branch whose changes overlap conflicting hunks with the base worktree; stale base with unmerged downstream changes; running the TUI apply action in a dirty worktree.","solutions":["Resolve the conflicting changes in the worktree, then retry the apply from the picker","Inspect the reported conflict outcome, update/rebase the branch onto the current base, and retry","Abort unrelated local changes or stash the worktree to a clean state before applying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// best-effort pre-check: ensure the worktree has no obvious conflicts before applying\nif git_status_has_unmerged_paths(&repo)? { /* warn the user */ }","typeGuard":null,"tryCatchPattern":"match apply::run(ctx, guard.write_permission(), op) {\n    Ok(ApplyOutcome::ConflictAborted(outcome)) => show_conflict_help(outcome),\n    Ok(_) => proceed(),\n    Err(e) => show_error(e),\n}","preventionTips":["Keep the base worktree clean before applying branches","Rebase the branch onto the current base regularly","Read the conflict outcome message and resolve hunks before retrying"],"tags":["git","conflict","tui"],"backgroundTag":"git-command-failed","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"}