fix: handle relative worktree linking files#2599
Draft
Sebastian Thiel (Byron) wants to merge 1 commit into
Draft
fix: handle relative worktree linking files#2599Sebastian Thiel (Byron) wants to merge 1 commit into
Sebastian Thiel (Byron) wants to merge 1 commit into
Conversation
Git 2.48 can link worktrees with relative paths. In that layout the checkout .git file points at the private git dir relative to the checkout, while worktrees/<id>/gitdir points back to the checkout relative to the private git dir. Discovery already handled the checkout-side gitdir file, but paths read from the private git dir were treated as-is. That made discovery from .git/worktrees/<id> and Repository::worktrees() proxy base resolution produce relative paths anchored to the process cwd instead of the gitdir file location. Add a plain-path reader that resolves relative values against the containing file, use it for worktree backlinks, and resolve those backlinks with filesystem-aware realpath behavior so symlinked repository paths keep Git semantics. Add regressions that exercise Git-2.48-style relative linking files, including symlinked access coverage, while constructing the fixture in a way that also runs on CI images with older Git. Git reference: /Users/byron/dev/github.com/git/git worktree.c:write_worktree_linking_files writes both relative links with `relative_path()`, and t/t2400-worktree-add.sh covers the resulting relative files. Validation: - cargo fmt --all --check - cargo test -p gix-discover --test discover - cargo test -p gix --test gix repository::worktree - git diff --check
0a6aa7f to
48723fc
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.
Summary
Handle Git 2.48 relative linked-worktree metadata by resolving plain backlink files relative to their containing
gitdirfile, and use filesystem-aware realpath resolution for worktree backlinks so symlinked repository access keeps Git-compatible semantics.Reported issue
Can you check that we can handle relative worktree paths, which are available as of Git 2.48?
For reference, here is the location of Git source code: /Users/byron/dev/github.com/git/git .
Git Reference
Git's
worktree.c::write_worktree_linking_files()writes both sides of relative worktree links withrelative_path(): the checkout.gitfile points to the private git dir, and.git/worktrees/<id>/gitdirpoints back to the checkout. Git'st/t2400-worktree-add.shcovers the resulting relative files forgit worktree add --relative-paths.Changes
gix-discoverhelper for plain path files whose relative values are anchored at the containing file.Repository::worktrees()proxy base lookup.Validation
cargo fmt --all --checkcargo test -p gix-discover --test discovercargo test -p gix --test gix repository::worktreegit diff --checkcodex review --commit 0a6aa7f870c6f4ad20f9af6932d4c78a738fbc2d