Skip to content

Fix WSL source control path separators - #7966

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/wsl-7021-sc-path-separators
Jul 9, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/wsl-7021-sc-path-separators

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • convert repository-relative pathspecs to POSIX separators when Git executes inside WSL
  • apply the boundary consistently to single and bulk stage, unstage, tracked discard, and untracked cleanup
  • preserve host-Git backslashes so valid POSIX filenames are not changed outside WSL

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 as tests\breakgit did 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 passed
  • pnpm run typecheck:node — passed
  • changed-file oxlint — passed
  • pnpm run check:max-lines-ratchet — passed
  • Win/Linux compatibility audit — no P0/P1 findings
  • pnpm run lint:switch-exhaustiveness — blocked by an existing current-main error in src/main/ipc/notification-authorization-status.ts:71 (undefined case missing)
  • full pnpm test — timed out after 10 minutes without reporting a failing test; affected suites above pass deterministically

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.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, root cause, and validation, but omits required Screenshots, AI Review Report, Security Audit, and Notes sections. Add the missing template sections and include the requested AI review, security audit, screenshots/no-visual-change note, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing WSL path separator handling in source control.
Linked Issues check ✅ Passed The changes normalize Git pathspecs for WSL and apply the fix to stage, unstage, discard, and cleanup paths, matching #7021's core requirement.
Out of Scope Changes check ✅ Passed The PR stays focused on WSL pathspec normalization and related tests, with no clear unrelated code changes introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/git/status-wsl-pathspecs.test.ts (1)

36-48: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Strengthen 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 whether bulkDiscardChanges classifies the file as tracked (git restore) or untracked (git clean). If isTrackedPathSpec fails 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b0febc and 6ccba4e.

📒 Files selected for processing (2)
  • src/main/git/status-wsl-pathspecs.test.ts
  • src/main/git/status.ts

@Jinwoo-H
Jinwoo-H merged commit 20ed764 into main Jul 9, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/wsl-7021-sc-path-separators branch July 9, 2026 22:04
Jinwoo-H added a commit that referenced this pull request Jul 10, 2026
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]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WSL Source Control passes Windows path separators to Git for nested files

1 participant