{"record":{"id":"81d91f44d626202e","repo":"zed-industries/zed","slug":"diff-has-no-unstaged-secondary","errorCode":null,"errorMessage":"diff has no unstaged secondary","messagePattern":"diff has no unstaged secondary","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/editor/src/git.rs","lineNumber":134,"sourceCode":"        for hunks in hunks {\n            let Some(buffer) = hunks.buffer else {\n                continue;\n            };\n\n            let ranges = hunks\n                .hunks\n                .into_iter()\n                .map(|hunk| hunk.buffer_range)\n                .collect::<Vec<_>>();\n            if ranges.is_empty() {\n                continue;\n            }\n            let secondary_diff = hunks.diff.read(cx).secondary_diff();\n            project\n                .update(cx, |project, cx| {\n                    if stage {\n                        let Some(secondary_diff) = secondary_diff else {\n                            return Err(anyhow::anyhow!(\"diff has no unstaged secondary\"));\n                        };\n                        project.stage_hunks(buffer, secondary_diff, ranges, cx)\n                    } else {\n                        project.unstage_uncommitted_hunks(buffer, hunks.diff, ranges, cx)\n                    }\n                })\n                .log_err();\n        }\n    }\n\n    fn render_hunk_controls(\n        &self,\n        row: u32,\n        status: &DiffHunkStatus,\n        hunk_range: Range<Anchor>,\n        is_created_file: bool,\n        line_height: Pixels,\n        editor: &Entity<Editor>,","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/editor/src/git.rs#L116-L152","documentation":"During stage/unstage of git hunks, a hunk's diff was read but its secondary_diff (the baseline diff against the other side, e.g. HEAD vs index) was None. The stage operation needs the secondary diff to apply the inverse/base representation, so this sentinel guard reports that the unstaged baseline is missing and the hunk cannot be staged through the normal path.","triggerScenarios":"Thrown at crates/editor/src/git.rs:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Skip the affected hunk and continue staging the remaining hunks, reporting which ones were skipped","Refresh the buffer diff (git status/index may have changed underneath) and retry before giving up","Fall back to invoking git apply/git add directly for the hunk's range"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}