Ignore configured hooks in git helpers (#22843)

## What
- Internal Git helper commands now ignore configured hook directories
during repository bookkeeping.

## Why
- These helper flows should stay consistent even when a repository has
hook-directory configuration of its own.

## How
- Pass a command-local `core.hooksPath` override in the shared helper
path and the Git-info helper path.
- Add regressions for the baseline index rewrite flow and the metadata
status flow.

## Validation
- `cargo fmt --manifest-path
/Users/bookholt/code/codex/codex-rs/Cargo.toml --all --check`
- `cargo test --manifest-path
/Users/bookholt/code/codex/codex-rs/Cargo.toml -p codex-git-utils`
- `cargo test --manifest-path
/Users/bookholt/code/codex/codex-rs/Cargo.toml -p codex-core
test_get_has_changes_`
This commit is contained in:
Chris Bookholt
2026-05-15 10:07:54 -07:00
committed by GitHub
Unverified
parent 7fa0007ea8
commit 9facdccb37
4 changed files with 100 additions and 1 deletions
+8 -1
View File
@@ -6,6 +6,8 @@ use std::process::Command;
use crate::GitToolingError;
const DISABLED_HOOKS_PATH: &str = if cfg!(windows) { "NUL" } else { "/dev/null" };
pub(crate) fn ensure_git_repository(path: &Path) -> Result<(), GitToolingError> {
match run_git_for_stdout(
path,
@@ -98,7 +100,12 @@ where
{
let iterator = args.into_iter();
let (lower, upper) = iterator.size_hint();
let mut args_vec = Vec::with_capacity(upper.unwrap_or(lower));
let mut args_vec = Vec::with_capacity(upper.unwrap_or(lower) + 2);
// Keep internal Git helper commands independent of configured hook directories.
args_vec.push(OsString::from("-c"));
args_vec.push(OsString::from(format!(
"core.hooksPath={DISABLED_HOOKS_PATH}"
)));
for arg in iterator {
args_vec.push(OsString::from(arg.as_ref()));
}