Skip to main content
← Back to list
01Issue
BugTriagedExtensionsPublic
Assigneesstack72

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:

  1. Drive-letter paths are misplaced. ensure_worktree with path: C:/repos/factory/work/ITEM and root: C:/repos/factory/work creates the worktree at <cwd>/repos/factory/work/ITEM, nested under the current directory, rather than at the requested path.
  2. Reuse always fails. Once a worktree exists, a second ensure_worktree call for the same path and branch fails with <path> is outside the worktree root <root> instead of reporting reused. 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, so C:/... gets prefixed with Deno.cwd(). On Windows Deno.cwd() returns a backslash path, for example C:\repos\factory.
  • canonicalPath() splits on / and calls Deno.realPathSync on /-joined prefixes. A segment like C: then resolves as "current directory on drive C", which is how the nested path comes about.
  • Once the directory exists, realPathSync returns a backslash path. isWithin(child, parent) compares with startsWith(parent + "/"), which never matches, so the root check fails.
  • For the same reason, the comparisons against git worktree list output (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/ITEM

Workaround

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/git 2026.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
02Bog Flow
✓OPEN◉TRIAGED○IN PROGRESS○SHIPPED+ 1 MOREASSIGNEDCLASSIFICATION

Triaged

10/16/2026, 9:31:35 PM

Click a lifecycle step above to view its details.

03Sludge Pulse
stack72 assigned stack7210/16/2026, 9:30:47 PM
Editable. Press Enter to edit.

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.