{"record":{"id":"895d9366dbb15fb7","repo":"jdx/mise","slug":"git-diff-failed-status","errorCode":null,"errorMessage":"git diff failed ({status})","messagePattern":"git diff failed \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/shadow.rs","lineNumber":1157,"sourceCode":"                \"--color=always\"\n            } else {\n                \"--color=never\"\n            },\n            &from,\n            &to,\n        ]);\n        if opts.stream {\n            let status = self.git.status_inherited(call)?;\n            return match status.code() {\n                Some(0) => Ok(DiffResult {\n                    output: vec![],\n                    changed: false,\n                }),\n                Some(1) => Ok(DiffResult {\n                    output: vec![],\n                    changed: true,\n                }),\n                _ => bail!(\"git diff failed ({status})\"),\n            };\n        }\n        let output = self.git.output_unchecked(call)?;\n        match output.status.code() {\n            Some(0) => Ok(DiffResult {\n                output: output.stdout,\n                changed: false,\n            }),\n            Some(1) => Ok(DiffResult {\n                output: output.stdout,\n                changed: true,\n            }),\n            _ => {\n                let stderr = String::from_utf8_lossy(&output.stderr);\n                bail!(\"git diff failed ({}): {}\", output.status, stderr.trim())\n            }\n        }\n    }","sourceCodeStart":1139,"sourceCodeEnd":1175,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/shadow.rs#L1139-L1175","documentation":"The in-process `git diff` plumbing used by the history feature is expected to exit 0 (no changes) or 1 (changes). Any other exit status means git itself failed (bad arguments, corrupt repo, missing object), and this bail reports the raw status code without stderr detail. It is an unexpected-termination guard around `git diff --exit-code` semantics.","triggerScenarios":"`git diff` (via PlumbingCall) exits with a code other than 0 or 1 — e.g. 128 from a corrupt or locked history repository, invalid tree/object ids, or bad diff arguments — inside the code path that constructs DiffResult (shadow.rs:~1157).","commonSituations":"A corrupted or partially-written history git store, an index.lock left behind by a crashed run, an oid referencing a pruned object, or running while another process rewrites the history repo.","solutions":["Run `git status`/`git fsck` inside the history store directory to find corruption or a stale index.lock, and fix or remove it.","Retry after ensuring no other mise process is concurrently writing history.","If objects are missing, re-capture the snapshots involved; the referenced ids may have been pruned.","Check mise version consistency — a store written by another version may hold incompatible objects."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# before diffing, ensure the history store is healthy\ngit -C \"$(mise history store-path)\" fsck --no-progress && \\\ntest ! -f \"$(mise history store-path)/index.lock\"","typeGuard":null,"tryCatchPattern":"// Rust\nmatch diff_snapshots(a, b) {\n    Ok(d) => show(d),\n    Err(e) if e.to_string().starts_with(\"git diff failed (\") => {\n        eprintln!(\"history git store unhealthy; run git fsck and retry\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Avoid concurrent mise history operations.","Cleanly shut down machines; crashes can leave the history repo locked/corrupt.","Run git fsck on the history store periodically."],"tags":["git","diff","process-exit"],"backgroundTag":"git-command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}