fix: let GIT_WORK_TREE override core.bare - #2841
Conversation
There was a problem hiding this comment.
💡 Codex Review
gitoxide/gix/src/open/repository.rs
Line 308 in 79e7dbf
When a relative GIT_WORK_TREE contains more .. components than the current directory's depth, Git and the OS resolve through the root, but gix_path::normalize() returns None here. The subsequent config.is_bare = Some(false) therefore creates a repository with workdir() == None and is_bare() == false, causing index/worktree status to fail with MissingWorkDir instead of using the explicitly requested worktree. Treat normalization failure as an error or normalize this valid environment path with filesystem semantics before marking the repository non-bare.
AGENTS.md reference: AGENTS.md:L16-L18
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
|
Oh, okay, good catch. Thanks! I reproduced it with a relative I updated the normalization only for the |
Signed-off-by: Daniel Castrillon <danielcadev@users.noreply.github.com>
That way, one can express another way with which Git handles worktrees. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>
67428ef to
8568341
Compare
The messiness probably stems from all the little details around opening a repo, but with enough coverage, it should be possible to find a solution that is more suited and not messy at all. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>
8568341 to
f03905e
Compare
Description
Honor the
GIT_WORK_TREEenvironment override when opening a repository configured withcore.bare=true.Git treats an explicit
GIT_WORK_TREEas an effective worktree and reports the repository as non-bare.gixpreviously retainedworkdir: None, which prevented downstream consumers such as Starship from computing repository status.The override is deliberately limited to
GIT_WORK_TREE. Acore.worktreeCLI override still does not supersedecore.bare, matching Git behavior.Related downstream issue: starship/starship#7609
Supersedes the downstream workaround proposed in starship/starship#7617.
#1985 and #1987 addressed the strict-config error associated with
GIT_WORK_TREE, but did not cover its interaction withcore.bare.Tests
GIT_WORK_TREE.-c core.worktree=...does not overridecore.bare.cargo fmt --all -- --checkgixcargo test -p gix --no-fail-fast: 410 passedAI assistance
Codex assisted with investigation, implementation, testing, and preparation of this pull request. I reviewed the changes and verified the behavior locally against Git.