worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Directory permissions not preserved on copy ignored step

Open RileyMathews opened this issue 8 months ago • 1 comments

When the copy ignored step is enabled for new worktree creation. Ignored directories do not have their permissions changed. This specifically is causing me an issue trying to spin up a local postgres instance via process compose that expects its data directory to have a specific permission.

How to reproduce In any repo

mkdir test
echo 'test' >> .gitignore
touch test/file
chmod 0700 test
wt switch -c new-branch
ls -al

And you will see the directory test has the permissions drwxr-xr-x not drwx------ as on the main worktree.

RileyMathews avatar Mar 17 '26 19:03 RileyMathews

Thanks for reporting this! I was able to reproduce the issue and identified the root cause: copy_dir_recursive_fallback() uses fs::create_dir_all() which creates directories with default permissions (0755), ignoring the source directory's permissions.

I've opened #1590 with a fix. A maintainer will review it shortly.

worktrunk-bot avatar Mar 17 '26 19:03 worktrunk-bot