Repository navigation
fix(git): run git inside the distro for folders on a WSL share - #451
Merged
amirlehmam merged 1 commit intoNov 13, 2026
Merged
Conversation
Windows git over \\wsl.localhost\<distro>\... gets the executable bit, symlinks
and ownership wrong: every executable file and symlink reads as modified, and
git refuses the repository ('dubious ownership'), so diff-provider treats the
folder as not a repository and falls back to the snapshot backend, which
ignores .gitignore.
Run git as 'wsl.exe -d <distro> --cd <path> --exec git' for those folders
instead. Linux git sees the real modes and symlinks and owns the repository, so
no config flags or safe.directory are needed, and a hostile repo config runs
inside WSL rather than on Windows. POSIX paths git prints (toplevel, worktree
list) are translated back to Windows paths. Other folders keep the absolute
Windows git. Managed worktrees (git-worktree.ts) are unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
For a pane whose cwd is
\\wsl.localhost\<distro>\…, wmux runs the Windowsgit.exeagainst the share. That goes wrong in two ways:fatal: detected dubious ownership.diff-provider.tsreads any failedgit rev-parseas "not a repository" and falls back to the snapshot backend, which ignores.gitignore(an ignoredmlruns/full of.jsonshowed up as changes). The Git view shows the raw error.core.filemode=true, Windows git sees every executable file and every symlink as modified.safe.directoryandcore.filemode/core.symlinksflags don't cleanly fix this: trusting a repo makes Windows git run its config (core.fsmonitor, diff drivers, …) on the host, andcore.symlinks=falsemakes git compare a link's target text with the file it finds, so symlinks still show as modified.Change
gitCommand(cwd, args)ingit-view.tsdecides how to run git for a folder:\\wsl.localhost\…,\\wsl$\…, either slash spelling):System32\wsl.exe -d <distro> --cd <posix path> --exec git …. Linux git sees the real modes and symlinks and owns the repo, so no flags and no trust decision are needed, and a hostile repo config runs inside WSL, not on Windows.--execmeans no shell re-parses the arguments, andwsl.exeis the absolute System32 one, for the same reasongitExecutable()is absolute.Details:
rev-parse --show-toplevel,worktree list) are POSIX; they are translated back to\\wsl.localhost\<distro>\…(orC:\…for/mnt/c) before being used as the next cwd (fromGitPath).GIT_OPTIONAL_LOCKS/GIT_TERMINAL_PROMPTare forwarded into WSL throughWSLENV.git()ingit-view.tsandgit()indiff-provider.ts.diff-provider.tsis CRLF in this repo and stays CRLF (2-line diff); the other files are LF.Not changed
git-worktree.ts(managed worktree create/remove) still uses Windows git. Those commands take Windows paths, so they need their own treatment.Cost
Each git call for a WSL folder now pays a
wsl.exestart. I haven't measured it.diff-provideralready coalesces concurrent calls and TTL-caches the repo probe, but the diff poll will spawnwsl.exewhere it used to spawngit.exe.Testing
WSLENVforwarding.git-view,diff-provider-gitandgit-worktree*suites pass (84 passed, 1 skipped);tscandeslintare clean.giton its defaultPATH.wsl.exe.🤖 Generated with Claude Code