fix(wsl): enumerate concrete repo paths for git safe.directory - #249
Closed
szymonos wants to merge 1 commit into
Closed
fix(wsl): enumerate concrete repo paths for git safe.directory#249szymonos wants to merge 1 commit into
szymonos wants to merge 1 commit into
Conversation
git's safe.directory does NOT honor shell globs - it matches literal paths only (the single special value `*` means "trust everything", which is too broad). The previous code added `/mnt/c/.../source/repos/*` and `/mnt/c/.../source/repos/*/*` as entries, which git treats as the literal strings "<...>/*" and never matches against real repo paths. Result: the "dubious ownership" warning was NOT actually suppressed on Windows-mount repos, despite the entries appearing in ~/.gitconfig. Fix: enumerate concrete repo directories on the Windows host using Get-ChildItem (fast - no WSL/host filesystem roundtrips per dir), filter to dirs that contain a .git subdir, translate each to its /mnt/c/... form, and pass them as separate safe.directory entries in a single bash invocation. Other improvements: - $env:USERPROFILE instead of /mnt/c/Users/$env:USERNAME so the Windows home dir is resolved correctly (Windows usernames don't always match the home dir name when they contain special chars like '.' or non-ASCII). - Drive letter detected from the actual repo path rather than hard-coded as 'c' - works if you keep your source tree on D:\. - Single bash invocation for all paths, idempotency check via grep -qFx against the existing list. Reported in code review of #246.
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.
Summary
Follow-up on review feedback on #246. The `safe.directory` block added there used shell-style globs (`/mnt/c/.../source/repos/` and `/* `), but git's `safe.directory` does not honor shell globs — it matches literal paths only. The single special value `*` means "trust everything," which is too broad. Result: the entries appeared in `~/.gitconfig` but did NOT actually suppress the "dubious ownership" warning on Windows-mount repos.
Approach (per @szymonos's suggestion)
Enumerate concrete repo directories on the Windows host rather than calling into WSL — the host-side enumeration is fast (no per-directory WSL/Windows filesystem roundtrips), and `safe.directory` needs literal paths anyway:
Other improvements bundled
Test plan
🤖 Generated with Claude Code