{"record":{"id":"5b1549df20e18181","repo":"GitoxideLabs/gitoxide","slug":"cannot-drop-stashed-commit","errorCode":null,"errorMessage":"cannot drop stashed commit {}","messagePattern":"cannot drop stashed commit (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/stash.rs","lineNumber":74,"sourceCode":"            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        }\n        let new = new.context(\"a stashed commit cannot disappear during a rewrite\")?;\n        if new == old {\n            continue;\n        }\n        if let Some(other) = destinations.insert(new, old) {\n            anyhow::bail!(\n                \"stashes at {} and {} would converge on {}\",\n                other.to_hex_with_len(7),\n                old.to_hex_with_len(7),\n                new.to_hex_with_len(7)\n            );\n        }\n        moves.push((reference.name().to_owned(), reference.target().into_owned(), old, new));\n    }\n\n    let mut forward = Vec::with_capacity(moves.len() * 2);\n    let mut rollback = Vec::with_capacity(moves.len() * 2);","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/stash.rs#L56-L92","documentation":"During a history rewrite, tix updates stash references so they follow their rewritten commits. If a stashed commit was removed by the rewrite (it is in the `removed` set), there is no new location to point the stash reference at, so tix refuses rather than silently dropping the saved worktree state. The error names the short hash of the stashed commit that could not be migrated.","triggerScenarios":"Calling `stash::rewrite_edits` (as part of a rewrite/rebase edit plan) when `rewritten` mapping plus a `removed` set indicate that a commit which owns a stash reference was dropped from the rewritten history.","commonSituations":"Dropping commits during an interactive rebase while those commits had associated tix stash state; amending histories where a stash-owning commit was filtered out.","solutions":["Unstash (apply) the saved worktree state for that commit before dropping it from history","Remove the stash reference explicitly if the saved state is no longer needed, then re-run the rewrite","Keep the commit in the rewritten history (don't mark it removed) so its stash can be migrated"],"exampleFix":"// before dropping the stash-owning commit\nrewrite.remove(commit_id);\n// after: restore the worktree state first\nstash::restore_manual(path, bare, commit_id)?;\nrewrite.remove(commit_id);","handlingStrategy":"try-catch","validationCode":"let stashed: Vec<ObjectId> = stash_refs(&repo)?;\nif stashed.iter().any(|id| rewrite.removed().contains(id)) {\n    anyhow::bail!(\"a stash-owning commit is marked for removal; unstash it first\");\n}","typeGuard":null,"tryCatchPattern":"match stash::rewrite_edits(&repo, plan) {\n    Err(e) if e.to_string().starts_with(\"cannot drop stashed commit\") => {\n        // extract the id from the message, unstash it, then retry\n    }\n    other => other?,\n}","preventionTips":["Before dropping commits in a rewrite, list tix stash references and unstash any whose commit is being dropped","Audit `removed` commits against stash refs in rewrite automation","Prefer amending over dropping when a commit carries saved worktree state"],"tags":["git","rewrite","stash","history"],"backgroundTag":"invalid-state-transition","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"}