core-agent-ide/codex-rs/utils/git
Thibault Sottiaux a59052341d
fix: parse git apply paths correctly (#8824)
Fixes apply.rs path parsing so 
- quoted diff headers are tokenized and extracted correctly, 
- /dev/null headers are ignored before prefix stripping to avoid bogus
dev/null paths, and
- git apply output paths are unescaped from C-style quoting.

**Why**
This prevents potentially missed staging and misclassified paths when
applying or reverting patches, which could lead to incorrect behavior
for repos with spaces or escaped characters in filenames.

**Impact**
I checked and this is only used in the cloud tasks support and `codex
apply <task_id>` flow.
2026-01-07 13:00:31 +00:00
..
src fix: parse git apply paths correctly (#8824) 2026-01-07 13:00:31 +00:00
Cargo.toml chore: add cargo-deny configuration (#7119) 2025-11-24 12:22:18 -08:00
README.md chore: merge git crates (#5909) 2025-10-29 12:11:44 +00:00

codex-git

Helpers for interacting with git, including patch application and worktree snapshot utilities.

use std::path::Path;

use codex_git::{
    apply_git_patch, create_ghost_commit, restore_ghost_commit, ApplyGitRequest,
    CreateGhostCommitOptions,
};

let repo = Path::new("/path/to/repo");

// Apply a patch (omitted here) to the repository.
let request = ApplyGitRequest {
    cwd: repo.to_path_buf(),
    diff: String::from("...diff contents..."),
    revert: false,
    preflight: false,
};
let result = apply_git_patch(&request)?;

// Capture the current working tree as an unreferenced commit.
let ghost = create_ghost_commit(&CreateGhostCommitOptions::new(repo))?;

// Later, undo back to that state.
restore_ghost_commit(repo, &ghost)?;

Pass a custom message with .message("…") or force-include ignored files with .force_include(["ignored.log".into()]).