{"record":{"id":"da136197bd615ad4","repo":"jdx/mise","slug":"git-diff-failed-da1361","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":1254,"sourceCode":"                && mode != \"160000\"\n            {\n                right_file.write_all(&self.cat_object(oid)?)?;\n            }\n            let left_name = left_file.path().to_string_lossy().to_string();\n            let right_name = right_file.path().to_string_lossy().to_string();\n            let diff = self.git.output_unchecked(PlumbingCall::new([\n                \"diff\",\n                \"--no-index\",\n                \"--no-ext-diff\",\n                \"--no-textconv\",\n                \"--patch\",\n                \"--color=never\",\n                \"--\",\n                &left_name,\n                &right_name,\n            ]))?;\n            if !matches!(diff.status.code(), Some(0 | 1)) {\n                bail!(\"git diff failed: {}\", String::from_utf8_lossy(&diff.stderr));\n            }\n            let text = String::from_utf8_lossy(&diff.stdout)\n                .replace(left_name.trim_start_matches('/'), &left_path)\n                .replace(right_name.trim_start_matches('/'), &right_path);\n            output.extend_from_slice(text.as_bytes());\n            if left.as_ref().map(|v| &v.0) != right.as_ref().map(|v| &v.0) {\n                output.extend_from_slice(\n                    format!(\n                        \"{right_path}: mode {} -> {}\\n\",\n                        left.as_ref().map_or(\"absent\", |v| v.0.as_str()),\n                        right.as_ref().map_or(\"absent\", |v| v.0.as_str())\n                    )\n                    .as_bytes(),\n                );\n            }\n        }\n        Ok(DiffResult { output, changed })\n    }","sourceCodeStart":1236,"sourceCodeEnd":1272,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/shadow.rs#L1236-L1272","documentation":"The no-index diff path writes decrypted snapshot contents to temporary files and runs `git diff --no-index` on them; exit codes 0 and 1 are both acceptable (1 just means differences). Any other status means the diff tool itself failed, and this bail includes git's stderr. It protects the caller from presenting garbage (empty/failed output) as a diff.","triggerScenarios":"`git diff --no-index --color=never -- <left_name> <right_name>` exits with a code outside {0,1} — e.g. 128 when a temp file disappeared, git is missing/broken, or arguments are malformed — at shadow.rs:1254 during decrypted plaintext diffing.","commonSituations":"The system git binary is missing or incompatible, /tmp filled up so temp plaintext files could not be written/read, or a sandbox/antivirus removed the temp files mid-diff.","solutions":["Check that `git` is installed, on PATH, and functional (`git --version`).","Free disk space in the temp directory — missing/unwritable temp plaintext files make the diff exit non-0/1.","Inspect the stderr in the message; if it reports a missing temp file, ensure nothing is cleaning /tmp during the operation.","Re-run the diff; transient interference (e.g. from security software) may be one-off."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# preflight the no-index diff dependencies\ngit --version && \\\ndf -h \"${TMPDIR:-/tmp}\" | awk 'NR==2{exit ($5+0 > 95 ? 1 : 0)}'","typeGuard":null,"tryCatchPattern":"// Rust\nmatch diff_no_index(left, right) {\n    Ok(text) => show(text),\n    Err(e) if e.to_string().starts_with(\"git diff failed:\") => {\n        eprintln!(\"no-index diff failed; check git install and temp space\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure git is installed and on PATH before using history diff features.","Keep ample free space in the temp directory for decrypted plaintext temp files.","Exclude /tmp (or TMPDIR) from aggressive cleaners during diff operations."],"tags":["git","diff","no-index"],"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"}