{"record":{"id":"f2879a7425ab2e7b","repo":"jdx/mise","slug":"git-diff-failed-conflicts","errorCode":null,"errorMessage":"Git diff failed ({}): {}","messagePattern":"Git diff failed \\((.+?)\\): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/dotfiles/conflicts.rs","lineNumber":217,"sourceCode":"    command.current_dir(repo.dir().parent().unwrap_or(repo.dir()));\n    command.args([\n        \"diff\",\n        \"--no-ext-diff\",\n        \"--no-textconv\",\n        \"--patch\",\n        if color {\n            \"--color=always\"\n        } else {\n            \"--color=never\"\n        },\n    ]);\n    command.arg(\"--no-index\").arg(\"--\");\n    command.arg(local.file.path()).arg(remote.file.path());\n    let mut output = command\n        .output()\n        .wrap_err_with(|| format!(\"running Git conflict comparison for {}\", display_path(path)))?;\n    if !matches!(output.status.code(), Some(0 | 1)) {\n        bail!(\n            \"Git diff failed ({}): {}\",\n            output.status,\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    let local_name = local.file.path().to_string_lossy();\n    let remote_name = remote.file.path().to_string_lossy();\n    output.stdout = String::from_utf8_lossy(&output.stdout)\n        .replace(local_name.as_ref(), &local.label)\n        .replace(local_name.trim_start_matches('/'), &local.label)\n        .replace(remote_name.as_ref(), &remote.label)\n        .replace(remote_name.trim_start_matches('/'), &remote.label)\n        .into_bytes();\n    Ok(output)\n}\n\nstatic AFTER_LONG_HELP: &str = color_print::cstr!(\n    r#\"<bold><underline>Examples:</underline></bold>","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/dotfiles/conflicts.rs#L199-L235","documentation":"git_diff runs `git diff --no-index` on the local and remote sides of a dotfile conflict. git exits 0 for identical files and 1 for differences; any other exit code means the diff itself failed (e.g. git missing, unreadable file), so the command bails with the exit status and trimmed stderr.","triggerScenarios":"`mise dotfiles` conflict handling invokes git_diff; git exits with a code other than 0 or 1 — git binary missing (code 127), one of the conflict-side file paths unreadable/deleted (code 2), or git config errors printing to stderr.","commonSituations":"A tracked dotfile was deleted after a checkpoint but before resolving conflicts; git not installed or a broken git shim earlier on PATH; file permissions changed so git cannot read one side.","solutions":["Check git is installed and working: `git --version` and `which git`","Verify both conflict-side files exist and are readable (ls -l on the paths from the error output)","Read the stderr text in the error message — it names the concrete git failure","Re-run the dotfiles command after fixing the file/git issue"],"exampleFix":"// before: file deleted mid-conflict so git diff exits 2\nls ~/.config/mise/dotfiles-conflicts/\n// after: restore or make both sides readable, then retry\nchmod u+r ~/.file && git --version","handlingStrategy":"validation","validationCode":"command -v git >/dev/null 2>&1 && test -r \"$local\" && test -r \"$remote\" || echo 'git or file unreadable'","typeGuard":null,"tryCatchPattern":"match DotfilesConflictDiff { Err(e) if e.to_string().contains(\"Git diff failed\") => check git installation and file readability, e => propagate }","preventionTips":["Keep git installed and first on PATH","Avoid deleting conflict-side files before resolving","Check file permissions after sync/restore tools run"],"tags":["git","dotfiles","cli"],"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"}