{"record":{"id":"e8661eebcd31e9a5","repo":"GitoxideLabs/gitoxide","slug":"cannot-stash-changes-with-unresolved-index-conflic","errorCode":null,"errorMessage":"cannot stash changes with unresolved index conflicts","messagePattern":"cannot stash changes with unresolved index conflicts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/stash.rs","lineNumber":139,"sourceCode":"    let workdir = repo\n        .workdir()\n        .context(\"stashing changes requires a worktree\")?\n        .to_owned();\n    let head = repo\n        .head_id()\n        .context(\"stashing changes requires a born HEAD\")?\n        .detach();\n    if head != id {\n        anyhow::bail!(\"changes can only be stashed at the current HEAD\");\n    }\n    if repo\n        .index_or_empty()\n        .context(\"could not inspect the index before stashing\")?\n        .entries()\n        .iter()\n        .any(|entry| entry.stage() != gix::index::entry::Stage::Unconflicted)\n    {\n        anyhow::bail!(\"cannot stash changes with unresolved index conflicts\");\n    }\n    let name = reference(id)?;\n    if repo.try_find_reference(name.as_ref())?.is_some() {\n        anyhow::bail!(\"{} already has saved worktree state\", id.to_hex_with_len(7));\n    }\n    drop(repo);\n    if !super::review::is_dirty(&workdir)? {\n        anyhow::bail!(\"there are no worktree or index changes to stash\");\n    }\n    let saved = save(\n        repository_path,\n        bare,\n        &workdir,\n        name,\n        format!(\"tix {}\", id.to_hex_with_len(7)),\n        \"tix commit stash\",\n        \"commit state\",\n    )?;","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/stash.rs#L121-L157","documentation":"Tix refuses to stash changes while the index still contains unresolved merge-conflict entries. Stashing would have to serialize conflict stages, which the save format does not support, so `save_manual` scans index entries and bails if any entry's stage is not `Unconflicted`. This prevents silently losing conflict information.","triggerScenarios":"Calling `stash::save_manual` (or the CLI `tix stash` equivalent) while the repository has conflicted index entries, i.e. after a merge/rebase/cherry-pick that produced conflicts and before they are resolved.","commonSituations":"Trying to stash mid-merge to \"clean up\" the worktree; interrupted rebases leaving stage-2/3 entries; cherry-picks with conflicts.","solutions":["Resolve the conflicts (`git add` resolved files or `git mergetool`) and then stash","Abort the in-progress merge/rebase (`git merge --abort`, `git rebase --abort`) to clear conflict stages, then stash","Check `git status` for \"Unmerged paths\" and clear them before invoking the stash"],"exampleFix":"// before stashing with conflicts\nstash::save_manual(path, bare, workdir, head_id)?;\n// after: verify the index is unconflicted\nlet repo = gix::open(path)?;\nlet clean = repo.index_or_empty()?.entries().iter()\n    .all(|e| e.stage() == gix::index::entry::Stage::Unconflicted);\nassert!(clean, \"resolve conflicts before stashing\");\nstash::save_manual(path, bare, workdir, head_id)?;","handlingStrategy":"validation","validationCode":"let repo = gix::open(path)?;\nlet conflicted = repo.index_or_empty()?.entries().iter()\n    .any(|e| e.stage() != gix::index::entry::Stage::Unconflicted);\nif conflicted {\n    anyhow::bail!(\"resolve index conflicts before stashing\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `git status` and ensure no \"Unmerged paths\" before stashing","Finish or abort in-progress merges/rebases/cherry-picks before stash automation runs","Add an index-stage check as a gate in scripts that call tix stash"],"tags":["git","merge-conflicts","index","stash"],"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-16T04:17:20.429Z"}