git: Allow MkdirAll on worktree-root paths#2115
Merged
Merged
Conversation
The worktree filesystem wrapper rejects `""`, `"."`, and `"/"` in `MkdirAll` via `validPath`, even though `validReadPath` was already relaxed to treat those paths as legitimate references to the worktree root. The asymmetry was deliberate for genuine mutations — mutating the root itself is not a sensible operation for `Create` or `Remove` — but `MkdirAll` on an existing directory is not a mutation: it asks the filesystem to ensure a directory exists, against one that always does. Short-circuit `MkdirAll` to a no-op for root-equivalents before `validPath` runs. `validPath` itself stays strict, so the other mutating operations continue to reject the root and the existing `TestValidPath` table is untouched. A new `TestWorktreeFilesystemMkdirAllRootIsNoop` locks in the no-op contract against the wrapper. Assisted-by: Claude Opus 4.7 Signed-off-by: Hidde Beydals <hidde@hhh.computer>
7cc8317 to
6b1eb62
Compare
pjbgf
pushed a commit
that referenced
this pull request
May 12, 2026
The worktree filesystem wrapper rejects `""`, `"."`, and `"/"` in `MkdirAll` via `validPath`, even though `validReadPath` was already relaxed to treat those paths as legitimate references to the worktree root. The asymmetry was deliberate for genuine mutations — mutating the root itself is not a sensible operation for `Create` or `Remove` — but `MkdirAll` on an existing directory is not a mutation: it asks the filesystem to ensure a directory exists, against one that always does. Short-circuit `MkdirAll` to a no-op for root-equivalents before `validPath` runs. `validPath` itself stays strict, so the other mutating operations continue to reject the root and the existing `TestValidPath` table is untouched. A new `TestWorktreeFilesystemMkdirAllRootIsNoop` locks in the no-op contract against the wrapper. Backport of #2115. Assisted-by: Claude Opus 4.7 Signed-off-by: Hidde Beydals <hidde@hhh.computer>
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.
The worktree filesystem wrapper rejects
"",".", and"/"inMkdirAllviavalidPath, even thoughvalidReadPathwas already relaxed to treat those paths as legitimate references to the worktree root. The asymmetry was deliberate for genuine mutations — mutating the root itself is not a sensible operation forCreateorRemove— butMkdirAllon an existing directory is not a mutation: it asks the filesystem to ensure a directory exists, against one that always does.Short-circuit
MkdirAllto a no-op for root-equivalents beforevalidPathruns.validPathitself stays strict, so the other mutating operations continue to reject the root and the existingTestValidPathtable is untouched. A newTestWorktreeFilesystemMkdirAllRootIsNooplocks in the no-op contract against the wrapper.