mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
## Why Memory requests have a one-second Git metadata deadline. Waiting for all Git lookups together discards an already observed HEAD or remote URL when the worktree scan exceeds that deadline. Shared status scans can also describe a different HEAD from the independent lookup. ## What changed - Publish HEAD, verified remote URLs, and worktree status incrementally, retaining available metadata at the memory request deadline. - Read HEAD and change status together using Git porcelain v2, and reject status observations that conflict with an independently observed HEAD. - Run a positive-only change probe over up to four recently modified root directories during memory extraction preparation. Use a completed probe only when full status is unknown and its HEAD matches the request metadata, without waiting for it before sending the request. ## Testing Add coverage for partial metadata at the deadline, delayed lookups, stale and unborn HEAD observations, positive-only probes, shared scans, and porcelain parsing. Extend remote credential redaction coverage to partial clones. GitOrigin-RevId: e7b7c250bfc0e23fb8962fcd5cd5febd7c69e2bd
codex-git-utils
Helpers for interacting with git, including patch application. The crate also
exposes a lightweight baseline API for internal directories that use git only
as a resettable diff mechanism: ensure_git_baseline_repository preserves a
usable root/.git baseline or creates one when it is missing or unusable,
reset_git_repository replaces root/.git with a fresh one-commit baseline,
and diff_since_latest_init returns structured file changes plus a unified
diff from that baseline to the current directory contents.
use std::path::Path;
use codex_git_utils::{apply_git_patch, ApplyGitRequest};
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)?;