jdx/mise · error

git diff failed ({status})

Error message

git diff failed ({status})

What it means

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.

Source

Thrown at src/system/history/shadow.rs:904

                "--color=always"
            } else {
                "--color=never"
            },
            &from,
            &to,
        ]);
        if opts.stream {
            let status = self.git.status_inherited(call)?;
            return match status.code() {
                Some(0) => Ok(DiffResult {
                    output: vec![],
                    changed: false,
                }),
                Some(1) => Ok(DiffResult {
                    output: vec![],
                    changed: true,
                }),
                _ => bail!("git diff failed ({status})"),
            };
        }
        let output = self.git.output_unchecked(call)?;
        match output.status.code() {
            Some(0) => Ok(DiffResult {
                output: output.stdout,
                changed: false,
            }),
            Some(1) => Ok(DiffResult {
                output: output.stdout,
                changed: true,
            }),
            _ => {
                let stderr = String::from_utf8_lossy(&output.stderr);
                bail!("git diff failed ({}): {}", output.status, stderr.trim())
            }
        }
    }

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Run the underlying git diff manually to see the underlying error (likely exit 128)
  2. Verify both snapshot oids/refs exist with `git cat-file -e <oid>`
  3. Repair or re-capture the corrupted history snapshot, or gc-prune issues via `git fsck`
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust: check both refs resolve before diffing
for oid in [&from_oid, &to_oid] {
    anyhow::ensure!(git.object_exists(oid)?, "snapshot object {oid} missing");
}

Try / catch

match differ.diff(from, to, paths) {
    Err(e) if e.to_string().contains("git diff failed") => {
        eprintln!("{e}; inspect git objects with `git fsck` and re-capture if corrupt");
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: Corrupt or pruned git objects backing the snapshots; invalid oid/ref arguments reaching git; git binary issues or a signal terminating the diff child.

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


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/895d9366dbb15fb7. Report an issue: GitHub.