{"record":{"id":"9c8224aae6188976","repo":"jdx/mise","slug":"git-diff-failed","errorCode":null,"errorMessage":"git diff failed ({}): {}","messagePattern":"git diff failed \\((.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/shadow.rs","lineNumber":1172,"sourceCode":"                    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    }\n\n    /// Decrypt only for this requested comparison. Git's no-index diff sees\n    /// private temporary files, never plaintext objects in the repository.\n    fn decrypted_diff(&self, a: &str, b: &str, opts: &DiffOpts) -> Result<DiffResult> {\n        use std::io::Write;\n        let mut paths = BTreeSet::new();\n        for (tree, prefix) in [\n            (a, opts.paths.as_ref().map(|p| p.0.as_str())),\n            (b, opts.paths.as_ref().map(|p| p.1.as_str())),\n        ] {\n            for entry in self.ls_tree(tree)? {\n                if entry.path.starts_with(\".mise-history/\") {\n                    continue;\n                }\n                if let Some(prefix) = prefix {","sourceCodeStart":1154,"sourceCodeEnd":1190,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/shadow.rs#L1154-L1190","documentation":"Same `git diff` exit-status contract as the sibling error, but this variant also appends git's trimmed stderr, giving the actual git error message. It fires when `git diff --exit-code` terminates with a status other than 0/1, so the failure reason from git is surfaced to the caller.","triggerScenarios":"`git diff` exits with an unexpected code (commonly 128) and the handler at shadow.rs:1172 formats `git diff failed ({}): {}` with git's stderr — e.g. unknown revision, bad object, lock-file contention, or malformed arguments.","commonSituations":"Diffing snapshots whose objects were garbage-collected or pruned, concurrent mise runs fighting over the history repo's lock, or a corrupted history store after a crash or disk-full event.","solutions":["Read the stderr in the message: it names the git failure (missing object, bad revision, lock) and fix that specific cause.","Remove a stale `index.lock` in the history store if git reports lock contention and no other run is active.","Run `git fsck` in the history store to detect and assess corruption; re-capture snapshots if objects are lost.","Avoid running multiple mise history operations concurrently."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# verify the referenced objects exist before diffing\ngit -C \"$(mise history store-path)\" cat-file -t <from-tree> && \\\ngit -C \"$(mise history store-path)\" cat-file -t <to-tree>","typeGuard":null,"tryCatchPattern":"// Rust\nmatch diff_snapshots(a, b) {\n    Ok(d) => show(d),\n    Err(e) => {\n        let msg = e.to_string();\n        if let Some(stderr) = msg.strip_prefix(\"git diff failed (\") {\n            eprintln!(\"git reported: {stderr}\"); // act on the concrete git error\n        }\n    }\n}","preventionTips":["Read the embedded stderr — it names the exact git failure.","Do not garbage-collect/prune the history store manually.","Serialize history operations; lock contention is a common cause."],"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"}