{"record":{"id":"50399bb4f5147c77","repo":"GitoxideLabs/gitoxide","slug":"msg-suffix","errorCode":null,"errorMessage":"{msg} {suffix}","messagePattern":"\\{msg\\} \\{suffix\\}","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"gitoxide-core/src/repository/dirty.rs","lineNumber":30,"sourceCode":"    mode: Mode,\n    out: &mut dyn std::io::Write,\n    format: OutputFormat,\n) -> anyhow::Result<()> {\n    if format != OutputFormat::Human {\n        bail!(\"JSON output isn't implemented yet\");\n    }\n    let is_dirty = repo.is_dirty()?;\n    let res = match (is_dirty, mode) {\n        (false, Mode::IsClean) => Ok(\"The repository is clean\"),\n        (true, Mode::IsClean) => Err(\"The repository has changes\"),\n        (false, Mode::IsDirty) => Err(\"The repository is clean\"),\n        (true, Mode::IsDirty) => Ok(\"The repository has changes\"),\n    };\n\n    let suffix = \"(not counting untracked files)\";\n    match res {\n        Ok(msg) => writeln!(out, \"{msg} {suffix}\")?,\n        Err(msg) => bail!(\"{msg} {suffix}\"),\n    }\n    Ok(())\n}\n","sourceCodeStart":12,"sourceCodeEnd":34,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gitoxide-core/src/repository/dirty.rs#L12-L34","documentation":"The dirty check concludes with a message about untracked files: the repository-local `is_dirty()` does not consider untracked files, so success/failure is reported with the suffix \"(not counting untracked files)\". When the result is the failure branch (repo dirty when checking IsClean, or clean when checking IsDirty), this message is raised as an error.","triggerScenarios":"Running `gix status dirty` (check in gitoxide-core/src/repository/dirty.rs): it errors when mode is IsClean but the repository has changes, or mode is IsDirty but the repository is clean — always appending the untracked-files caveat.","commonSituations":"CI pipelines asserting a clean working tree fail because tracked files were modified (untracked-only changes are ignored by this check); developers expecting untracked files to count as dirty get a confusing result.","solutions":["Commit or revert the modified tracked files so the repository is clean (for IsClean mode)","Add untracked files to the index if they should count towards dirtiness","Note the check ignores untracked files — clean them with `git clean` equivalents or adjust expectations","Use the opposite Mode if you intended the other assertion"],"exampleFix":"// before\ndirty::check(repo, Mode::IsClean, out, format)?; // fails when tracked changes exist\n// after\n// commit or stash changes first, then:\ndirty::check(repo, Mode::IsClean, out, format)?;","handlingStrategy":"try-catch","validationCode":"// pre-check tracked-file dirtiness before asserting IsClean\nlet is_dirty = repo.is_dirty()?;\nif is_dirty {\n    eprintln!(\"working tree has tracked changes; commit or stash first\");\n}","typeGuard":null,"tryCatchPattern":"match dirty::check(repo, Mode::IsClean, &mut out, format) {\n    Ok(()) => println!(\"clean (excluding untracked files)\"),\n    Err(e) => {\n        eprintln!(\"not clean: {e}\");\n        std::process::exit(1);\n    }\n}","preventionTips":["Remember this check ignores untracked files — handle them separately","Commit or stash changes before asserting cleanliness in CI","Use Mode::IsDirty when you want to assert the tree is actually dirty"],"tags":["cli","status","dirty-state"],"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"}