{"record":{"id":"e7e086f96dad1a9f","repo":"GitoxideLabs/gitoxide","slug":"could-not-inspect-a-reference-before-editing-err","errorCode":null,"errorMessage":"could not inspect a reference before editing: {err}","messagePattern":"could not inspect a reference before editing: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/rebase.rs","lineNumber":411,"sourceCode":"    committer: gix::actor::Signature,\n    expected_refs: Option<Vec<ExpectedRef>>,\n    checkout_reference: Option<gix::refs::FullName>,\n    checkout_after_finish: bool,\n    pins: Vec<ObjectId>,\n    delete_refs: Vec<(gix::refs::FullName, Target)>,\n    enrichment: Option<(ObjectId, BString)>,\n}\n\npub(crate) fn capture_refs(repo: &gix::Repository, scope: &[ObjectId], tips: &[ObjectId]) -> Result<Vec<ExpectedRef>> {\n    let scope: HashSet<_> = scope.iter().copied().collect();\n    let tips: HashSet<_> = tips.iter().copied().collect();\n    let mut out = Vec::new();\n    let mut seen = HashSet::new();\n    for reference in repo.references()?.all()? {\n        let reference = match reference {\n            Ok(reference) => reference,\n            Err(err) if is_missing_ref(&*err) => continue,\n            Err(err) => anyhow::bail!(\"could not inspect a reference before editing: {err}\"),\n        };\n        if matches!(\n            reference.name().category(),\n            Some(Category::Tag | Category::RemoteBranch)\n        ) || super::undo::is_queue_ref(reference.name().as_bstr())\n        {\n            continue;\n        }\n        let Some(old) = reference.try_id().map(gix::Id::detach) else {\n            continue;\n        };\n        if scope.contains(&old) && seen.insert(reference.name().to_owned()) {\n            out.push(ExpectedRef {\n                name: reference.name().to_owned(),\n                old: Some(old),\n                target: old,\n                new: Some(old),\n                follows_tip: tips.contains(&old),","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/rebase.rs#L393-L429","documentation":"Before performing an edit, tix scans all references to collect tags, remote branches, and undo-queue refs that need updating. Most per-reference errors are tolerated (missing refs are skipped), but any other failure to inspect a reference aborts the whole edit, because proceeding could rewrite history while missing refs that point into it.","triggerScenarios":"Iterating `repo.references()?.all()?` when the underlying ref-backend iterator yields an `Err` that is not a missing-ref: corrupted or unreadable loose/packed refs, permission problems on `.git/refs`, or a storage-backend error.","commonSituations":"A damaged repository (truncated packed-refs, stale lock files, partially deleted refs); refs files unreadable due to file permissions or sandboxing; worktrees with unusual ref backends.","solutions":["Run `git fsck` and `git pack-refs --all` to detect and repair corrupted or malformed references, then retry.","Check read permissions on `.git/refs`, `packed-refs`, and any worktree ref directories; fix ownership/permissions.","Remove stale ref lock files (`.git/refs/**.lock`) left by crashed processes.","If a specific ref is irrecoverable, delete and recreate it before running the edit."],"exampleFix":"// before: corrupted packed-refs entry aborts the scan\n// error: could not inspect a reference before editing: ...\n\n// after: repair refs first\ngit fsck --no-progress\ngit pack-refs --all --prune","handlingStrategy":"try-catch","validationCode":"// Shell: pre-flight ref health check before editing\ngit fsck --no-progress || exit 1\ntest -r .git/packed-refs || true","typeGuard":null,"tryCatchPattern":"// Rust\nmatch plan_edits(repo) {\n    Err(e) if e.to_string().starts_with(\"could not inspect a reference\") => {\n        eprintln!(\"repair refs (git fsck / pack-refs) and retry\");\n    }\n    other => other?,\n}","preventionTips":["Run `git fsck` and `git pack-refs --all` regularly and before history edits.","Keep `.git/refs` readable and free of stale `.lock` files.","Back up the repository before large history rewrites."],"tags":["git","refs","repository-corruption","permissions"],"backgroundTag":"resource-not-found","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}