{"record":{"id":"3aff46f3ee253e9c","repo":"GitoxideLabs/gitoxide","slug":"review-requires-a-clean-index-and-worktree","errorCode":null,"errorMessage":"review requires a clean index and worktree","messagePattern":"review requires a clean index and worktree","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/review.rs","lineNumber":320,"sourceCode":"        checkout,\n        report,\n    )? {\n        super::rebase::Perform::Complete(outcome) => {\n            let finished = outcome\n                .map(review)\n                .context(\"finishing review did not produce a commit\")?;\n            Ok(Finish::Complete(Finished {\n                commit: finished,\n                outcome,\n            }))\n        }\n        super::rebase::Perform::Conflict(conflict) => Ok(Finish::Conflict(conflict)),\n    }\n}\n\npub(super) fn ensure_clean(workdir: &Path) -> Result<()> {\n    if is_dirty(workdir)? {\n        anyhow::bail!(\"review requires a clean index and worktree\");\n    }\n    Ok(())\n}\n\npub(super) fn is_dirty(workdir: &Path) -> Result<bool> {\n    let output = Command::new(\"git\")\n        .arg(\"-C\")\n        .arg(workdir)\n        .args([\"status\", \"--porcelain=v1\", \"--untracked-files=all\"])\n        .output()\n        .context(\"could not inspect worktree status\")?;\n    if !output.status.success() {\n        anyhow::bail!(\"{}\", String::from_utf8_lossy(&output.stderr).trim());\n    }\n    Ok(!output.stdout.is_empty())\n}\n\nfn next_reference(repo: &gix::Repository) -> Result<gix::refs::FullName> {","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/review.rs#L302-L338","documentation":"Starting or finishing a review requires a clean index and worktree, because review setup rewrites HEAD, the index, and possibly the worktree via git plumbing. `ensure_clean` runs `git status --porcelain` and refuses to proceed if any entry is reported.","triggerScenarios":"Calling review `start` or `finish_with_progress` while there are unstaged modifications, staged changes, or untracked files in the worktree.","commonSituations":"Uncommitted edits from ordinary development left in the tree; editor or build artifacts that are untracked; ignored-but-not-ignored generated files; a partially staged change forgotten from an earlier session.","solutions":["Commit or stash your changes (`git stash -u` to include untracked files), then retry.","Add intended files and commit them (`git add -A && git commit`).","Discard unwanted changes explicitly (`git checkout -- . && git clean -fd`) if they are disposable."],"exampleFix":"// before\nreview::start(repo, ...)?; // fails on dirty worktree\n// after: clean first, then start\n// git stash -u\nreview::start(repo, ...)?;","handlingStrategy":"validation","validationCode":"let status = std::process::Command::new(\"git\")\n    .args([\"status\", \"--porcelain=v1\", \"--untracked-files=all\"])\n    .output()?;\nif !status.stdout.is_empty() {\n    return Err(anyhow::anyhow!(\"commit or stash changes before starting a review\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Adopt a habit of `git status` before running review commands.","Use `git stash -u` to sweep untracked files before review operations.","Configure editor/build artifacts as gitignored so they never dirty the tree."],"tags":["git","dirty-worktree","precondition-failed"],"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"}