{"record":{"id":"9490ee9cf29e6ff8","repo":"GitoxideLabs/gitoxide","slug":"an-undo-entry-requires-the-exact-previous-referenc","errorCode":null,"errorMessage":"an undo entry requires the exact previous reference value","messagePattern":"an undo entry requires the exact previous reference value","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/undo.rs","lineNumber":370,"sourceCode":"                existing.after = change.after;\n            }\n            None => {\n                by_name.insert(change.name.clone(), change);\n            }\n        }\n    }\n    Ok(by_name\n        .into_values()\n        .filter(|change| change.before != change.after)\n        .collect())\n}\n\nfn state_from_expected(expected: &PreviousValue) -> Result<State> {\n    match expected {\n        PreviousValue::MustNotExist => Ok(State::Missing),\n        PreviousValue::MustExistAndMatch(target) => Ok(state_from_target(target)),\n        PreviousValue::Any | PreviousValue::MustExist | PreviousValue::ExistingMustMatch(_) => {\n            bail!(\"an undo entry requires the exact previous reference value\")\n        }\n    }\n}\n\nfn state_from_target(target: &Target) -> State {\n    match target {\n        Target::Object(id) => State::Object(*id),\n        Target::Symbolic(name) => State::Symbolic(name.clone()),\n    }\n}\n\nfn state_from_target_ref(target: gix::refs::TargetRef<'_>) -> State {\n    match target {\n        gix::refs::TargetRef::Object(id) => State::Object(id.to_owned()),\n        gix::refs::TargetRef::Symbolic(name) => State::Symbolic(name.to_owned()),\n    }\n}\n","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/undo.rs#L352-L388","documentation":"Conversion failure in `edit::undo::state_from_expected`, called from `from_edit` when building undo queue state from a planned reference change. A `PreviousValue` expresses what a ref must have looked like before the edit; only `MustNotExist`, `MustExistAndMatch(target)` map cleanly onto an undo State. The wildcard variants (`Any`, `MustExist`, `Existing...`) carry no concrete value to restore, so an exact previous value cannot be recorded and the conversion bails. It indicates an undo entry was planned against a reference whose pre-edit value was not pinned; fix by ensuring the edit pins the exact expected prior ref value before it can be undone.","triggerScenarios":"Thrown at gix-tix/src/edit/undo.rs:370 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Record the undo entry against the reference's actual current value so the expected PreviousValue matches what the repository contains","Regenerate the undo queue (drop the stale entries) so subsequent expectations are rebuilt from the real reference states","If the reference's prior value is genuinely unknown, use PreviousValue::Any rather than asserting a specific prior state"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}