openai/codex · error · GitToolingError

git command ` ` failed with status

Error message

git command `{command}` failed with status {status}: {stderr}

What it means

Variant of GitToolingError fired when a spawned git command exits with a non-zero status. Carries the command line, exit status, and captured stderr so callers can diagnose why the git operation (worktree snapshot, etc.) failed.

Solutions

  1. Read the stderr field for git's own diagnostic (e.g. bad revision, lock conflict)
  2. Verify the repository state is valid for the operation (clean HEAD, no stale index.lock)
  3. Re-run git manually with the same arguments to reproduce and fix the underlying cause
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/git-utils/src/errors.rs:11 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/8eea0d9971647a9d. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/git-utils/src/errors.rs:11

use std::path::PathBuf;
use std::process::ExitStatus;
use std::string::FromUtf8Error;

use thiserror::Error;
use walkdir::Error as WalkdirError;

/// Errors returned while managing git worktree snapshots.
#[derive(Debug, Error)]
pub enum GitToolingError {
    #[error("git command `{command}` failed with status {status}: {stderr}")]
    GitCommand {
        command: String,
        status: ExitStatus,
        stderr: String,
    },
    #[error("git command `{command}` produced non-UTF-8 output")]
    GitOutputUtf8 {
        command: String,
        #[source]
        source: FromUtf8Error,
    },
    #[error("{path:?} is not a git repository")]
    NotAGitRepository { path: PathBuf },
    #[error("path {path:?} must be relative to the repository root")]
    NonRelativePath { path: PathBuf },
    #[error("path {path:?} escapes the repository root")]
    PathEscapesRepository { path: PathBuf },
    #[error("failed to process path inside worktree")]

View on GitHub (pinned to 339751715c)