jdx/mise · error
Git diff failed ( )
Error message
Git diff failed ({}): {} What it means
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.
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
Example fix
// before: file deleted mid-conflict so git diff exits 2 ls ~/.config/mise/dotfiles-conflicts/ // after: restore or make both sides readable, then retry chmod u+r ~/.file && git --version
Defensive patterns
Strategy: validation
Validate before calling
command -v git >/dev/null 2>&1 && test -r "$local" && test -r "$remote" || echo 'git or file unreadable'
Try / catch
match DotfilesConflictDiff { Err(e) if e.to_string().contains("Git diff failed") => check git installation and file readability, e => propagate } Prevention
- Keep git installed and first on PATH
- Avoid deleting conflict-side files before resolving
- Check file permissions after sync/restore tools run
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- tracking declarations updated, but could not commit the…
- a branch name is required
- a glob is required
- a repository url is required
- adoption requires confirmation; review the directory and…
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/f2879a7425ab2e7b.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/dotfiles/conflicts.rs:217
command.current_dir(repo.dir().parent().unwrap_or(repo.dir()));
command.args([
"diff",
"--no-ext-diff",
"--no-textconv",
"--patch",
if color {
"--color=always"
} else {
"--color=never"
},
]);
command.arg("--no-index").arg("--");
command.arg(local.file.path()).arg(remote.file.path());
let mut output = command
.output()
.wrap_err_with(|| format!("running Git conflict comparison for {}", display_path(path)))?;
if !matches!(output.status.code(), Some(0 | 1)) {
bail!(
"Git diff failed ({}): {}",
output.status,
String::from_utf8_lossy(&output.stderr).trim()
);
}
let local_name = local.file.path().to_string_lossy();
let remote_name = remote.file.path().to_string_lossy();
output.stdout = String::from_utf8_lossy(&output.stdout)
.replace(local_name.as_ref(), &local.label)
.replace(local_name.trim_start_matches('/'), &local.label)
.replace(remote_name.as_ref(), &remote.label)
.replace(remote_name.trim_start_matches('/'), &remote.label)
.into_bytes();
Ok(output)
}
static AFTER_LONG_HELP: &str = color_print::cstr!(
r#"<bold><underline>Examples:</underline></bold>View on GitHub (pinned to 533346cc37)