{"record":{"id":"8259c32b599b28d5","repo":"zed-industries/zed","slug":"failed-to-stage","errorCode":null,"errorMessage":"Failed to stage:\n{}","messagePattern":"Failed to stage:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git/src/repository.rs","lineNumber":1664,"sourceCode":"            .spawn(async move {\n                let working_directory = working_directory?;\n                let git_binary = git_binary?;\n                let output = git_binary\n                    .build_command(&[\"config\", \"--get\", \"commit.template\"])\n                    .output()\n                    .await\n                    .context(\"failed to run git config --get commit.template\")?;\n\n                let raw_path = String::from_utf8_lossy(&output.stdout).trim().to_string();\n                if !output.status.success() || raw_path.is_empty() {\n                    return Ok(None);\n                }\n\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","sourceCodeStart":1646,"sourceCodeEnd":1682,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/git/src/repository.rs#L1646-L1682","documentation":"ensure! guard failing when `git update-index --add --cacheinfo` (staging the freshly hashed blob into the index) exits non-zero. It means the blob SHA produced by hash-object could not be written into the index for the given path — typically a corrupted or locked index, or a SHA/path mismatch.","triggerScenarios":"Thrown at crates/git/src/repository.rs:1653 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the embedded git stderr for reasons like 'index file smaller than expected' or lock file contention","Remove stale .git/index.lock if present and retry","Run `git status` to verify index integrity","Fall back to a normal `git add` of the path if index manipulation 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-14T00:17:10.932Z"}