{"record":{"id":"83e9b2af07965b6c","repo":"zed-industries/zed","slug":"failed-to-apply-stash","errorCode":null,"errorMessage":"Failed to apply stash:\n{}","messagePattern":"Failed to apply stash:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git/src/repository.rs","lineNumber":2651,"sourceCode":"                    .args(paths.iter().map(|p| p.as_unix_str()))\n                    .output()\n                    .await?;\n\n                anyhow::ensure!(\n                    output.status.success(),\n                    \"Failed to stash:\\n{}\",\n                    String::from_utf8_lossy(&output.stderr)\n                );\n                Ok(())\n            })\n            .boxed()\n    }\n\n    fn stash_staged(\n        &self,\n        message: Option<String>,\n        env: Arc<HashMap<String, String>>,\n    ) -> BoxFuture<'_, Result<()>> {\n        let git = self.git_binary_in_worktree();\n        self.executor\n            .spawn(async move {\n                let git = git?;\n                // `--staged` cannot be expressed as a pathspec: a partially staged\n                // file would otherwise have its unstaged hunks stashed too.\n                let mut args = vec![\"stash\", \"push\", \"--quiet\", \"--staged\"];\n                if let Some(message) = message.as_deref() {\n                    args.extend_from_slice(&[\"--message\", message]);\n                }\n                let output = git.build_command(&args).envs(env.iter()).output().await?;\n\n                anyhow::ensure!(\n                    output.status.success(),\n                    \"Failed to stash staged changes (requires git 2.35 or newer):\\n{}\",\n                    String::from_utf8_lossy(&output.stderr)\n                );\n                Ok(())","sourceCodeStart":2633,"sourceCodeEnd":2669,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/git/src/repository.rs#L2633-L2669","documentation":"ensure! guard failing when `git stash apply [stash@{N}]` exits non-zero. Applying the stashed changes failed — usually due to conflicts with current worktree contents or a stale stash index reference.","triggerScenarios":"Thrown at crates/git/src/repository.rs:2637 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect stderr for conflict messages and surface them to the user; apply keeps the stash entry so nothing is lost","Re-check the stash list before applying; stash@{N} may point elsewhere after changes","Commit or stash current changes before applying to reduce conflict likelihood","Retry apply after the user resolves conflicts"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}