fix: preserve symlinks when copying directories #46
+2
−2
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.
Pull Request
Description
Use
cp -RPinstead ofcp -rincopy_directories()to prevent symlink dereferencing, which breaks dependency manager binaries (e.g.,node_modules/.bin/*).Motivation
When copying directories like
node_modulesto new worktrees, symlinks were being dereferenced into regular files. This breaks executables that rely on symlinks (common in npm/pnpm/yarn).Fixes #45
Type of Change
Testing
Manual Testing Checklist
Tested on:
Core functionality tested:
git gtr new <branch>- Create worktreegit gtr go <branch>- Navigate to worktreegit gtr editor <branch>- Open in editor (if applicable)git gtr ai <branch>- Start AI tool (if applicable)git gtr rm <branch>- Remove worktreegit gtr list- List worktreesgit gtr config- Configuration commands (if applicable)Test Steps
Create test directory with symlinks:
Configure gtr to copy the directory:
git gtr config set gtr.copy.includeDirs test-deps --localCreate a worktree:
Verify symlinks are preserved:
ls -la "$(git gtr go test-symlink)/test-deps/.bin/"Expected behavior: Symlink preserved (
lrwxr-xr-x -> ../real-package/index.js)Actual behavior: Symlink preserved (
lrwxr-xr-x -> ../real-package/index.js)Breaking Changes
Checklist
Before submitting this PR, please check:
git gtr(production) and./bin/gtr(development)Additional Context
cp -RPis POSIX-compliant and supported on macOS, Linux (GNU coreutils), FreeBSD, and OpenBSD.License Acknowledgment
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.