Rename backup archive root so extraction dir mode isn't clobbered #10
Reference in New Issue
Block a user
Delete Branch "fix/backup-root-dir-mode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Follow-up to #9. The backup transform
s,^\./,workspace/,rewrites the workspace contents (./foo→workspace/foo) but leaves tar's root member as a bare./. That./entry carries the source root's mode/mtime, so extracting the archive stamps them onto the extraction directory itself (e.g. an unexpected chmod/mtime on wherever the user unpacks it).Fix
Match the leading
.instead of./(s,^\.,workspace,), so tar's root member is renamed./→workspace. The archive then carries a properworkspace/directory entry and no bare./, and the extraction directory is left untouched. Contents, hidden files, excludes, symlink targets, and theflags=rhhardlink handling are all unchanged.Verification (in-container, exact production script)
workspace/+home-claude/; no./member.0755directory leaves it0755(previously the root entry could reset it).node_modules/targetstill excluded (0 leaked).home-claude/still un-nested;workspace/.githistory preserved.cargo checkpasses.🤖 Generated with Claude Code