{"record":{"id":"b2aac8bc02206459","repo":"GitoxideLabs/gitoxide","slug":"could-not-inspect-a-stash-reference-before-rebasin","errorCode":null,"errorMessage":"could not inspect a stash reference before rebasing: {err}","messagePattern":"could not inspect a stash reference before rebasing: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/stash.rs","lineNumber":57,"sourceCode":"}\n\npub(super) struct RewriteEdits {\n    pub forward: Vec<RefEdit>,\n    pub rollback: Vec<RefEdit>,\n}\n\npub(super) fn rewrite_edits(\n    repo: &gix::Repository,\n    rewritten: &HashMap<ObjectId, Option<ObjectId>>,\n    removed: &HashSet<ObjectId>,\n) -> Result<RewriteEdits> {\n    let mut moves = Vec::new();\n    let mut destinations = HashMap::<ObjectId, ObjectId>::new();\n    for reference in repo.references()?.all()? {\n        let reference = match reference {\n            Ok(reference) => reference,\n            Err(err) => {\n                return Err(anyhow::anyhow!(\n                    \"could not inspect a stash reference before rebasing: {err}\"\n                ));\n            }\n        };\n        let old = match associated_commit(reference.name().as_bstr()) {\n            Ok(Some(id)) => id,\n            Ok(None) => continue,\n            Err(err) => {\n                tracing::warn!(name = %reference.name(), error = %err, \"ignored malformed tix stash reference\");\n                continue;\n            }\n        };\n        let Some(new) = rewritten.get(&old).copied() else {\n            continue;\n        };\n        if removed.contains(&old) {\n            anyhow::bail!(\"cannot drop stashed commit {}\", old.to_hex_with_len(7));\n        }","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/stash.rs#L39-L75","documentation":"Before rewriting edits, `rewrite_edits` in gix-tix's stash module scans all references to find stash-associated commits. If iterating references yields an Err for any single ref, it returns \"could not inspect a stash reference before rebasing: {err}\" instead of skipping, to avoid silently dropping stash state during a rebase.","triggerScenarios":"Running a tix rebase/rewrite when `repo.references()?.all()?` returns an error for some reference — dangling oid after gc, corrupt ref entry, or unreadable ref storage.","commonSituations":"Repositories with pruned objects still referenced by refs; damaged packed-refs; interrupted git operations leaving inconsistent refs.","solutions":["Run `git fsck` to locate the broken reference, then repair or delete it","Delete stale stash refs (refs/stash, refs/tix/...) that point to missing objects","Re-run the rebase after ref repair"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify all refs resolve before a stash-aware rebase\nfor r in repo.references()?.all()? {\n    let r = r.map_err(|e| anyhow::anyhow!(\"stale ref: {e}\"))?;\n    let _ = r.try_id()?;\n}","typeGuard":null,"tryCatchPattern":"match rewrite_edits(...) {\n    Err(e) if e.to_string().contains(\"stash reference\") => {\n        eprintln!(\"repair refs (git fsck) before rebasing\");\n    }\n    other => other?,\n}","preventionTips":["Keep stash refs valid — don't prune objects they point to","Run `git fsck` after interrupted operations","Snapshot repos before aggressive gc"],"tags":["git","stash","references","rebase"],"backgroundTag":"entity-not-found","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}