Repository navigation
fix(tools): keep file mode and symlinks when writing atomically - #488
Merged
Merged
Conversation
write_atomic renamed a fresh tempfile over the target. The tempfile is created 0600 and the rename replaces whatever the path was, so every edit made through write/edit/apply_patch/ast_edit/format: - dropped the execute bit from scripts and narrowed 0644 files to 0600; - created new files 0600 instead of the usual umask mode; - turned a symlink into a regular file, leaving the real file untouched. Follow a symlink to its target before writing, copy an existing file's permissions onto the tempfile, and create new files with 0666 filtered by the umask. Windows keeps the old path: it has no mode bits to carry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mrnasil
enabled auto-merge (squash)
November 25, 2026 14:53
Merged
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.
write_atomicrenamed a fresh tempfile over the target. The tempfile is created0600, and the rename replaces whatever the path was. So every edit made throughwrite,edit,apply_patch,ast_editand the formatter had three side effects:0644files became0600.0600instead of the usual umask mode.The fix:
0666, filtered by the umask.Tests, Unix only: mode
0751survives a write; a new file gets the same mode asfs::writegives; writing through a link updates the target and keeps the link; a dangling link and a non-directory parent are reported as errors. Run on Linux (WSL), whereatomic.rshas 100% line coverage.🤖 Generated with Claude Code