git: Stop validating symlink target paths#2114
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts worktreeFilesystem.Symlink to validate only the link name (the path being created in the worktree) and to stop applying worktree path validation rules to the symlink target, aligning behavior with upstream Git and fixing checkouts of repositories that contain symlinks with absolute or ..-escaping targets (ref: #2107).
Changes:
- Stop running
validPathon symlink targets; validate only the symlink link name. - Update/expand tests to assert that symlink targets are treated as opaque strings and can be arbitrary.
- Add an end-to-end checkout test ensuring worktree checkout succeeds and remains clean with “non-worktree-contained” symlink targets.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| worktree_fs.go | Changes symlink validation to check only the link path, not the target. |
| worktree_fs_test.go | Updates symlink validation tests to reject dangerous link names but allow arbitrary targets. |
| worktree_test.go | Adds an integration test covering checkout of symlinks with arbitrary targets. |
The Symlink wrapper was running validPath on both the target and the link. Targets are an opaque string the kernel resolves at use time, so legitimate worktrees commonly contain symlinks pointing to absolute paths or escaping via "..". Validating them as worktree paths rejected those checkouts. Containment is enforced on the link name, which is where the wrapper actually controls placement. Assisted-by: Claude Opus 4.7 <[email protected]> Signed-off-by: Paulo Gomes <[email protected]>
hiddeco
approved these changes
May 12, 2026
This was referenced May 12, 2026
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.
The Symlink wrapper was running validPath on both the target and the link. Targets are an opaque string the kernel resolves at use time, so legitimate worktrees commonly contain symlinks pointing to absolute paths or escaping via "..". Validating them as worktree paths rejected those checkouts. Containment is enforced on the link name, which is where the wrapper actually controls placement.
Reverts 0ae66bd, which added validation on symlink target which does not align with upstream.
Relates to #2107.