Relationships
#3521 ensure_worktree on Windows: drive-letter paths are treated as relative, and reusing an existing worktree always fails
Opened by rogueco · 10/15/2026
Summary
@swamp/git v2026.10.13.1 handles worktree paths as POSIX paths. On Windows this causes two problems:
- Drive-letter paths are misplaced.
ensure_worktreewithpath: C:/repos/factory/work/ITEMandroot: C:/repos/factory/workcreates the worktree at<cwd>/repos/factory/work/ITEM, nested under the current directory, rather than at the requested path. - Reuse always fails. Once a worktree exists, a second
ensure_worktreecall for the same path and branch fails with<path> is outside the worktree root <root>instead of reportingreused. Both paths in that message are printed with backslashes.
Cause (from reading models/_lib/operations.ts)
absolutePath(path, base)treats anything not starting with/as relative, soC:/...gets prefixed withDeno.cwd(). On WindowsDeno.cwd()returns a backslash path, for exampleC:\repos\factory.canonicalPath()splits on/and callsDeno.realPathSyncon/-joined prefixes. A segment likeC:then resolves as "current directory on drive C", which is how the nested path comes about.- Once the directory exists,
realPathSyncreturns a backslash path.isWithin(child, parent)compares withstartsWith(parent + "/"), which never matches, so the root check fails. - For the same reason, the comparisons against
git worktree listoutput (C:/...), such as the primary-checkout and overlap checks, never match on Windows. The safety checks are effectively off.
Results of calling canonicalPath directly with cwd = C:\repos\factory:
C:/repos/factory/work/ITEM => C:\/C:\repos\factory/C:/repos/factory/work/ITEM
/repos/factory/work/ITEM => C:\repos\factory/work/ITEM
work/ITEM => C:\/C:\repos\factory/work/ITEMWorkaround
Pass drive-less absolute paths (/repos/factory/work/ITEM), which resolve against the current drive. That fixes creation only; reusing an existing worktree still fails.
Expected
On Windows, accept drive-letter and backslash paths, normalise both sides of every comparison the same way (for example @std/path resolve/normalize, plus case-insensitive comparison on Windows), and make re-running ensure_worktree for an existing worktree report reused.
Environment
- Windows 11 Pro 10.0.26300
- swamp 20261014.204224.0-sha.8d6dfb6c
@swamp/git2026.10.13.1- git for Windows
Upstream repository: https://github.com/swamp-club/swamp-extensions
Environment
- Extension:
@swamp/git@2026.10.13.1 - swamp:
20261014.204224.0-sha.8d6dfb6c - OS:
windows(x86_64) - Deno:
2.9.7 - Shell:
C:\Program Files\Git\bin\bash.exe
Open
No activity in this phase yet.
system commented 10/15/2026, 9:15:25 PM
Classified automatically when this issue was filed.
- Source: Extensions
If you feel this classification is incorrect, add a ripple to tell us so.
Sign in to post a ripple.