{"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":904,"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":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/shadow.rs#L886-L922","documentation":"The fast path of diff runs git diff directly and interprets its exit code: 0 means no changes, 1 means changes, anything else is an unexpected failure. This variant bails when the exit code is neither 0 nor 1 (or is absent), without stderr detail included in the message.","triggerScenarios":"diff invokes git and the child process exits with a code other than 0/1 (e.g. 128 for a bad object id, or a signal-killed process) in the fast (non-decrypted) code path.","commonSituations":"Corrupt or pruned git objects backing the snapshots; invalid oid/ref arguments reaching git; git binary issues or a signal terminating the diff child.","solutions":["Run the underlying git diff manually to see the underlying error (likely exit 128)","Verify both snapshot oids/refs exist with `git cat-file -e <oid>`","Repair or re-capture the corrupted history snapshot, or gc-prune issues via `git fsck`"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Rust: check both refs resolve before diffing\nfor oid in [&from_oid, &to_oid] {\n    anyhow::ensure!(git.object_exists(oid)?, \"snapshot object {oid} missing\");\n}","typeGuard":null,"tryCatchPattern":"match differ.diff(from, to, paths) {\n    Err(e) if e.to_string().contains(\"git diff failed\") => {\n        eprintln!(\"{e}; inspect git objects with `git fsck` and re-capture if corrupt\");\n    }\n    other => other?,\n}","preventionTips":["Verify snapshot oids exist before diffing","Avoid pruning git objects backing active history snapshots","Run `git fsck` periodically on the history repository"],"tags":["git","diff","process"],"backgroundTag":"git-command-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}