fix: don't apply the caller's GIT_INDEX_FILE or GIT_WORK_TREE to a new clone - #3035
Merged
Sebastian Thiel (Byron) merged 2 commits intoOct 2, 2026
Conversation
…a new clone `clone::PrepareFetch` opened the repository it creates with the caller's repository-local environment overrides. When the calling process runs inside a Git hook of another repository, those variables describe that other repository: Git sets `GIT_INDEX_FILE` for `pre-commit`, and hook runners may set `GIT_WORK_TREE`. The checkout then wrote the clone's index to the caller's index file, and with `GIT_WORK_TREE` its files into the caller's worktree. A new clone is never the repository these variables describe, so open it the way submodules and worktrees are already opened, with `open::Options::without_repository_environment_overrides()`. Authentication, proxy and protocol variables still apply.
Member
|
Thanks! While Git expects certain variables (in hooks) to be cleared, no matter how I think about it, for this API it seems like the wrong choice to adhere to that. So let's change it, and declare the 'deviation' instead. |
Contributor
Author
|
Sebastian Thiel (@Byron) no problem! Also, I noticed a few issues came up in regards to linting, those seem related to rust's latest stable update rather than my code changes though. Glad to assist on fixing them if you'd like me to. |
Sebastian Thiel (Byron)
force-pushed
the
fix/clone-ignores-caller-repository-env
branch
from
October 2, 2026 04:45
e770f19 to
0f08c8e
Compare
Member
|
All good, thanks, I am taking it from here. |
- Kind of unrelated, and a pre-existing problem, but still worth seeing it addressed.
- [P2] Preserve editor and notes overrides when isolating a clone — /Users/byron/dev/github.com/GitoxideLabs/gitoxide.fix-clone-ignores-caller-repository-env/gix/src/clone/mod.rs:120-120
When `GIT_EDITOR` or `GIT_NOTES_REF` is set, this also suppresses those settings: `apply_environment_overrides()` gates them in the same `core` group as `GIT_WORK_TREE`. The returned clone consequently selects the wrong editor (potentially `None`) and notes reference, while reopening the same repository restores both. Preserve these non-location settings while filtering worktree/index overrides; reference Git retains them, consistent with the [Git-baseline guidance](AGENTS.md#L24).
CI on Rust 1.99 failed after the stable toolchain update, before reaching
all of the clone tests. The `lint` job rejected deprecated `fetch_update`
calls, existing emptiness assertions, and `#[must_use]` attributes generated
by `async_trait`. Rustdoc also flagged links in re-exported documentation.
Keep `fetch_update` for Rust 1.88 compatibility, allow the new emptiness lint
centrally, and scope the generated-code allowances to the affected modules.
The Linux ARM, ARM32, and Windows 32-bit tests failed because Rust 1.99
changed `TryFromIntError` messages. Normalize both new messages through the
existing `gix_testtools::redact_debug_snapshot()` helper, use that helper for
the pack-header snapshot, and check both signed and unsigned conversion failures.
The concrete errors, classifications, and diagnostic context remain asserted.
Validation: all four `just clippy -D warnings -A unknown-lints --no-deps`
configurations pass on Rust 1.99. The 46 targeted clone, parallel, checkout,
allocation, and snapshot tests pass on Rust 1.99; five snapshot-related tests
also pass on Rust 1.98. Formatting is unchanged.
Assisted-by: GPT 6.0 Astra
Co-authored-by: GPT 6.0 Astra <codex@openai.com>
Sebastian Thiel (Byron)
force-pushed
the
fix/clone-ignores-caller-repository-env
branch
from
October 2, 2026 04:59
0f08c8e to
95043b9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasks
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
A new clone now ignores the caller's repository-local environment overrides, including
GIT_INDEX_FILEandGIT_WORK_TREE. Programs cloning from inside a Git hook therefore keep the new repository's index and checkout inside the clone instead of writing into the hook's repository. This is a documented deviation fromgit clone.PrepareFetchreusesopen::Options::without_repository_environment_overrides(). Editor and notes preferences (GIT_EDITORandGIT_NOTES_REF) are still honored, as are authentication, proxy, and protocol settings. Regression coverage uses disposable repositories and checks that repository paths are ignored while these preferences survive.The original clone fix was contributed by Victor Araújo (@any-victor) with Claude Code assistance. Byron's review update preserves editor and notes settings. Codex amended that review commit with fixes for failures introduced by the Rust 1.99 toolchain update: MSRV-compatible allowances for deprecated atomic operations, scoped lint allowances for generated async code, and stable integer-conversion diagnostic snapshots through the existing test helper.
Validation on Rust 1.99: all four
just clippy -D warnings -A unknown-lints --no-depsconfigurations, bothjust docconfigurations, formatting, and 46 targeted clone, parallel, checkout, allocation, and snapshot tests pass. Five snapshot-related tests also pass on Rust 1.98. GitHub CI is being monitored for the pushed head.This addresses cloning from hook-launched mise tasks.