git: Allow MkdirAll on worktree-root paths · go-git/go-git@776d00f · GitHub
Skip to content

Commit 776d00f

Browse files
committed
git: Allow MkdirAll on worktree-root paths
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>
1 parent 3235bb6 commit 776d00f

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎worktree_fs.go‎

Lines changed: 8 additions & 0 deletions

‎worktree_test.go‎

Lines changed: 26 additions & 0 deletions

0 commit comments

Comments
 (0)