Skip to content

fix: resolve relative core.worktree from real git dir#2671

Merged
Sebastian Thiel (Byron) merged 2 commits into
mainfrom
fix-worktree-path-resolution
Jun 23, 2026
Merged

fix: resolve relative core.worktree from real git dir#2671
Sebastian Thiel (Byron) merged 2 commits into
mainfrom
fix-worktree-path-resolution

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Jun 23, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-5.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #2052

Summary

  • Resolve relative core.worktree config values against a symlink-resolved git-dir base when opening through a symlinked .git.
  • Preserve existing relative path behavior when the git-dir path does not traverse symlinks.
  • Add a regression fixture and submodule status test for a symlinked top-level .git, detached worktree, and populated submodule.

Git baseline

  • git.git t1510-repo-setup.sh documents that core.worktree is relative to the git dir.
  • git.git t7409-submodule-detached-work-tree.sh validates submodules in detached worktrees pointed to by core.worktree.

Validation

  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix submodule::open::status_uses_detached_worktree_from_symlinked_git_dir -- --exact --nocapture
  • GIX_TEST_IGNORE_ARCHIVES=1 GIX_TEST_FIXTURE_HASH=sha256 cargo test -p gix --test gix submodule::open::status_uses_detached_worktree_from_symlinked_git_dir -- --exact --nocapture
  • cargo test -p gix --test gix submodule::open::status_uses_detached_worktree_from_symlinked_git_dir -- --exact --nocapture
  • GIX_TEST_FIXTURE_HASH=sha256 cargo test -p gix --test gix submodule::open::status_uses_detached_worktree_from_symlinked_git_dir -- --exact --nocapture
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix submodule::open -- --nocapture
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix --test gix repository::worktree::with_core_worktree_config -- --nocapture
  • cargo test -p gix --test gix
  • cargo test -p gix --no-default-features --test gix submodule::open::status_uses_detached_worktree_from_symlinked_git_dir -- --exact --nocapture
  • cargo test -p gix --test gix linked_worktree_proxy_base -- --nocapture
  • git diff --check
  • codex review --commit 8a4d48196bde30fcf5300bc3159210b9afa6607e found no correctness issues.

@Byron Sebastian Thiel (Byron) force-pushed the fix-worktree-path-resolution branch 2 times, most recently from 8a4d481 to 16eb8ba Compare June 23, 2026 07:07
@Byron Sebastian Thiel (Byron) marked this pull request as ready for review June 23, 2026 07:08
Copilot AI review requested due to automatic review settings June 23, 2026 07:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16eb8ba9af

ℹ️ 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".

Comment thread gix/tests/fixtures/make_core_worktree_repo.sh
Issue #2052 reports that `gix status` can fail for a repository opened through
a symlinked top-level `.git` when `core.worktree` is relative and the repository
contains submodules. The submodule worktree was anchored from the symlink parent
instead of the actual repository git dir, producing paths outside the intended
detached worktree.

Resolve relative `core.worktree` paths against a symlink-resolved git-dir base
only when resolving symlinks changes the git-dir path. This follows Git setup
behavior without changing normal relative path preservation for repositories
without symlinked git dirs.

Git baseline: git.git t1510-repo-setup.sh documents that `core.worktree` is
relative to the git dir, and t7409-submodule-detached-work-tree.sh validates
submodules in detached worktrees pointed to by `core.worktree`.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron Sebastian Thiel (Byron) force-pushed the fix-worktree-path-resolution branch from 16eb8ba to b1c1cce Compare June 23, 2026 07:21
Let's try to run these tests on Windows as well. They have a chance,
given that the scripts executed correctly.
Copilot AI review requested due to automatic review settings June 23, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Byron Sebastian Thiel (Byron) merged commit a7625fa into main Jun 23, 2026
32 checks passed
@Byron Sebastian Thiel (Byron) deleted the fix-worktree-path-resolution branch June 23, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree resolves to wrong path

3 participants