jdx/mise · error

git diff failed ( )

Error message

git diff failed ({status})

What it means

The in-process `git diff` plumbing used by the history feature is expected to exit 0 (no changes) or 1 (changes). Any other exit status means git itself failed (bad arguments, corrupt repo, missing object), and this bail reports the raw status code without stderr detail. It is an unexpected-termination guard around `git diff --exit-code` semantics.

Solutions

  1. Run `git status`/`git fsck` inside the history store directory to find corruption or a stale index.lock, and fix or remove it.
  2. Retry after ensuring no other mise process is concurrently writing history.
  3. If objects are missing, re-capture the snapshots involved; the referenced ids may have been pruned.
  4. Check mise version consistency — a store written by another version may hold incompatible objects.
Defensive patterns

Strategy: retry

Validate before calling

# before diffing, ensure the history store is healthy
git -C "$(mise history store-path)" fsck --no-progress && \
test ! -f "$(mise history store-path)/index.lock"

Try / catch

// Rust
match diff_snapshots(a, b) {
    Ok(d) => show(d),
    Err(e) if e.to_string().starts_with("git diff failed (") => {
        eprintln!("history git store unhealthy; run git fsck and retry");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: `git diff` (via PlumbingCall) exits with a code other than 0 or 1 — e.g. 128 from a corrupt or locked history repository, invalid tree/object ids, or bad diff arguments — inside the code path that constructs DiffResult (shadow.rs:~1157).

Common situations: A corrupted or partially-written history git store, an index.lock left behind by a crashed run, an oid referencing a pruned object, or running while another process rewrites the history repo.

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@533346cc37 (2026-09-17). Data as JSON: /api/errors/895d9366dbb15fb7. Report an issue: GitHub.

Appendix: source

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

                "--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 533346cc37)