fix(desktop): handle Windows simple-git binary paths with spaces - #64812
fix(desktop): handle Windows simple-git binary paths with spaces#64812tuancookiez-hub wants to merge 1 commit into
Conversation
simple-git rejects binary paths containing spaces (e.g. C:\Program Files\Git\cmd\git.exe — the default Git for Windows install path), causing the review pane to show 'No diff to show'. Guard against spaces in gitFor() by falling back to bare 'git', which Node resolves via PATH on Windows regardless of install location. Closes NousResearch#64810
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the simple-git validation failure — the premise is confirmed on current main: gitFor() passes gitBin directly to simple-git (apps/desktop/electron/git-review-ops.ts:45-46), and the locked simple-git 3.36.0 supports unsafe.allowUnsafeCustomBinary for this case.
Problems
- The new fallback to bare
gitloses the resolved executable.resolveGitBinary()explicitly supports Hermes PortableGit installations that are never on PATH (apps/desktop/electron/main.ts:1829-1864), so this can replace a valid space-containing binary with an unavailable command. apps/desktop/electron/git-review-ops.test.ts:5-21has no coverage for a space-containing custom binary path.
Suggested changes
- Preserve
gitBinand enable simple-git's documentedunsafe.allowUnsafeCustomBinaryoption for the resolver-provided binary instead of falling back to PATH. - Add a focused construction regression test for
C:\\Program Files\\Git\\cmd\\git.exe.
Automated hermes-sweeper review.
| // simple-git rejects Windows binary paths containing spaces (e.g. | ||
| // C:\Program Files\Git\cmd\git.exe — the default Git for Windows install | ||
| // path). Fall back to bare 'git' which Node resolves via PATH. | ||
| const binary = gitBin && !gitBin.includes(' ') ? gitBin : 'git' |
There was a problem hiding this comment.
This fallback breaks the resolver's PortableGit path: resolveGitBinary() intentionally selects %LOCALAPPDATA%\\hermes\\git before PATH and documents that it is never on PATH (apps/desktop/electron/main.ts:1829-1864). Preserve gitBin and use simple-git's unsafe.allowUnsafeCustomBinary option instead.
|
This is now fixed on main via PR #67612 (merged commit e361c5e). The landed fix takes the same direction you identified — keep the internally resolved absolute binary and use simple-git's Thanks for staying on this bug across both iterations (#60156 and this v2) — credit to you, @unsupportedpastels (#64713, whose commit landed with authorship preserved), and @wenyi-xydigit (#55337, first submitter) for converging on the fix. |
Thank you for the update and for the kind shout-out! I'm really glad to see this fix land on main. A big thanks to @unsupportedpastels for taking the final implementation across the finish line, and to the maintainers for reviewing and merging it. It's great to see the community collaborate on this — from the initial report (#55337) through the iterations to a solid resolution. I'll keep an eye out for the next release to verify the fix in action. Thanks again to everyone involved! |
What does this PR do?
Fixes a Windows-only bug where the desktop review pane shows "No diff to show" because
simple-gitrejects binary paths containing spaces (e.g.C:\Program Files\Git\cmd\git.exe— the default Git for Windows install path).resolveGitBinary()inmain.tscorrectly resolves the git binary to an absolute path. When that path contains spaces,simple-git's internal spawn fails silently — everygit.status(),git.diffSummary(), etc. call throws, and the review pane's catch blocks return empty results.Root Cause
gitFor()inapps/desktop/electron/git-review-ops.tspasses the resolved binary path directly tosimpleGit():simple-gitdoes not quote the binary path when spawning, so a space inC:\Program Files\Git\...breaks the spawn.Fix
Guard against spaces in the binary path — fall back to bare
'git'(which Node resolves via PATH):On Windows,
gitis always on PATH regardless of install location (the installer adds it), so the fallback is safe. On macOS/Linux,resolveGitBinary()returns a PATH-resolved'git'(no spaces), so behavior is unchanged.Note: the two
execFile(gitBin || 'git', ...)calls in the same file are not affected — Node'sexecFileproperly quotes arguments with spaces.Related Issue
Closes #64810
Type of Change
How to Test
Reproduction (Windows, before fix):
C:\Program Files\Git\)Ctrl+Gto open the review paneAfter fix:
Non-Windows / PATH-only: No change in behavior —
gitis still resolved from PATH.Checklist
else, early returns)