{"record":{"id":"77a04410e30474e8","repo":"zed-industries/zed","slug":"failed-to-unstage","errorCode":null,"errorMessage":"Failed to unstage:\n{}","messagePattern":"Failed to unstage:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git/src/repository.rs","lineNumber":1677,"sourceCode":"\n                let path = PathBuf::from(&raw_path);\n                let path = if let Some(path) = raw_path.strip_prefix(\"~/\") {\n                    paths::home_dir().join(path)\n                } else if path.is_relative() {\n                    working_directory.join(path)\n                } else {\n                    path\n                };\n\n                let template = match std::fs::read_to_string(&path) {\n                    Ok(s) if !s.trim().is_empty() => Some(s),\n                    Err(err) => {\n                        log::warn!(\"failed to read commit template {}: {}\", path.display(), err);\n                        None\n                    }\n                    _ => None,\n                };\n\n                Ok(template.map(|template| GitCommitTemplate { template }))\n            })\n            .boxed()\n    }\n\n    fn set_index_text(\n        &self,\n        path: RepoPath,\n        content: Option<Vec<u8>>,\n        env: Arc<HashMap<String, String>>,\n        is_executable: bool,\n    ) -> BoxFuture<'_, anyhow::Result<()>> {\n        let git = self.git_binary();\n        self.executor\n            .spawn(async move {\n                let mode = if is_executable { \"100755\" } else { \"100644\" };\n\n                if let Some(content) = content {","sourceCodeStart":1659,"sourceCodeEnd":1695,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/git/src/repository.rs#L1659-L1695","documentation":"ensure! guard failing when `git update-index --force-remove -- <path>` exits non-zero while trying to unstage a file by removing it from the index. Fires when the path is not in the index, the index is locked/corrupt, or git rejects the operation.","triggerScenarios":"Thrown at crates/git/src/repository.rs:1666 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read git's stderr from the error to see the concrete failure","Check for a stale .git/index.lock file and remove it","Verify the path exists in the index via `git ls-files`","Fall back to `git restore --staged <path>` if update-index keeps failing"],"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"}