Skip to content

Process hard links to one file once - #275

Merged
costajohnt merged 1 commit into
mainfrom
fix/272-hardlinks
Nov 20, 2026
Merged

costajohnt merged 1 commit into
mainfrom
fix/272-hardlinks

Conversation

@costajohnt

Copy link
Copy Markdown
Owner

Fixes #272

collect deduplicated the walk by canonical path, and canonicalizing doesn't resolve hard links to one name. So two links to one file went to two workers at once, and one could fail with "file changed while formatting".

On unix the dedup key is now (dev, ino) from the file's metadata, keeping the first name in walk order. The second name is dropped silently, the same as a file named twice on the command line today. The canonical path is still the key when metadata fails, and on Windows, where std's file index is behind the unstable windows_by_handle, so Windows behavior is unchanged.

Tests (unix only): two hard links in one directory, for write mode (5 runs), --check and --lint. On main all three fail on every run of 10, with write mode giving three different results across those runs (exit 0 with "reformatted 1 of 2 files", or exit 2 with "a.groovy: file changed while formatting", or the same for b.groovy). On this branch they passed 10 of 10.

Release builds of main and this branch give byte-identical stdout, stderr and exit codes for --check --diff and --lint over the gate corpus, which has no hard links.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwxvdT99Lm5gtULaszKTmo

collect deduplicated files by canonical path, which can't see hard links,
so two names for one file went to two workers at once and one could fail
with "file changed while formatting". On unix, deduplicate by (dev, ino),
keeping the first name in walk order; the canonical path stays the key
when metadata fails and on Windows, where std's file index is unstable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwxvdT99Lm5gtULaszKTmo
@costajohnt
costajohnt merged commit ef2491b into main Nov 20, 2026
14 checks passed
@costajohnt
costajohnt deleted the fix/272-hardlinks branch November 20, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Two hard links to one file are formatted concurrently

1 participant