Repository navigation
Fix WSL source control path separators - #7966
Conversation
Windows path validation returns backslash-separated relative paths. Convert them at the WSL Git pathspec boundary so nested stage, unstage, and discard operations target the intended files.
📝 WalkthroughWalkthroughThe literalPathspec helper in src/main/git/status.ts was updated to accept a GitRuntimeOptions parameter and normalize backslashes to forward slashes when a WSL distro is specified. All call sites—stageFile, unstageFile, discardChanges, bulkDiscardChanges, bulkStageFiles, bulkUnstageFiles, listTrackedPathSpecs, and cleanUntrackedPaths—now pass runtime options through to this helper for consistent pathspec construction. A new test file, status-wsl-pathspecs.test.ts, was added with mocked git runner calls to verify correct literal pathspec formatting (POSIX separators under WSL, backslash preservation on host) across staging, unstaging, discard, and bulk operations, including fallback handling for untracked files. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/git/status-wsl-pathspecs.test.ts (1)
36-48: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winStrengthen the tracked-mutation test to assert specific git subcommands.
The test at line 47 asserts all 8 pathspecs equal
:(literal)tests/breakgit, but this passes regardless of whetherbulkDiscardChangesclassifies the file as tracked (git restore) or untracked (git clean). IfisTrackedPathSpecfails to match due to separator differences, the file would be cleaned instead of restored — a data-loss path that this test would not catch.Consider asserting the specific subcommands invoked, similar to the untracked test at lines 62-74, to verify the correct branch is taken.
♻️ Suggested assertion strengthening
it('uses POSIX separators for tracked file mutations executed inside WSL', async () => { await stageFile(worktreePath, windowsRelativePath, wslOptions) await unstageFile(worktreePath, windowsRelativePath, wslOptions) await bulkStageFiles(worktreePath, [windowsRelativePath], wslOptions) await bulkUnstageFiles(worktreePath, [windowsRelativePath], wslOptions) await discardChanges(worktreePath, windowsRelativePath, wslOptions) await bulkDiscardChanges(worktreePath, [windowsRelativePath], wslOptions) - const pathspecs = gitExecFileAsyncMock.mock.calls.flatMap(([args]) => - (args as string[]).filter((arg) => arg.startsWith(':(literal)')) - ) - expect(pathspecs).toEqual(Array(8).fill(':(literal)tests/breakgit')) + const commands = gitExecFileAsyncMock.mock.calls.map(([args]) => (args as string[])[0]) + expect(commands).toEqual([ + 'add', // stageFile + 'restore', // unstageFile + 'add', // bulkStageFiles + 'restore', // bulkUnstageFiles + 'ls-files', // discardChanges tracked check + 'restore', // discardChanges tracked restore + 'ls-files', // bulkDiscardChanges listTrackedPathSpecs + 'restore' // bulkDiscardChanges tracked restore (NOT 'clean') + ]) + + const pathspecs = gitExecFileAsyncMock.mock.calls.flatMap(([args]) => + (args as string[]).filter((arg) => arg.startsWith(':(literal)')) + ) + expect(pathspecs).toEqual(Array(8).fill(':(literal)tests/breakgit')) })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 64408bd8-be58-41ae-b391-efe5d49707ba
📒 Files selected for processing (2)
src/main/git/status-wsl-pathspecs.test.tssrc/main/git/status.ts
Clean auto-merge, no conflicts (109 files, +7490 from main). Brought in: - Codex WSL runtime status hooks (#7969); WSL/SSH agent path resolution past shell aliases (#7867); WSL source-control path separators (#7966); WSL GitLab-auth wake fix (#7967); WSL Codex usage RPC refresh (#7567/#7658) - Improve workspace cleanup list (#7053) + background removal - mobile: per-host connection log + Tailscale wedge recovery (#7984/#7980), wake slept agents on mobile worktree open (#7906) - Harden layout validation, watcher lifecycle, connection robustness (#7924) - Disable experimental worktree card style by default (#7977) Perf-branch structure preserved (clean auto-merge). typecheck 0 errors; lint 0 errors. CI is the release gate (local runs skipped per env lag). Co-authored-by: Orca <[email protected]>
Summary
Fixes #7021
Root cause
Windows IPC path validation correctly resolved file paths for safety, then returned the repository-relative result from
path.relative(). For local projects configured to run Git in WSL, that Windows-form relative path was passed unchanged into a literal Git pathspec, so nested paths such astests\breakgitdid not match Linux paths.Validation
pnpm exec vitest run --config config/vitest.config.ts src/main/git/status-wsl-pathspecs.test.ts src/main/git/status.test.ts src/main/git/status-pathspec-literals.test.ts src/main/git/status-discard-symlink.test.ts src/main/ipc/filesystem.test.ts— 175 passedpnpm run typecheck:node— passedoxlint— passedpnpm run check:max-lines-ratchet— passedpnpm run lint:switch-exhaustiveness— blocked by an existing current-main error insrc/main/ipc/notification-authorization-status.ts:71(undefinedcase missing)pnpm test— timed out after 10 minutes without reporting a failing test; affected suites above pass deterministically