Skip to content

Fix: Console launch fails when Windows username contains spaces - #12841

Merged
mstv merged 2 commits into
gitextensions:masterfrom
apoorvdarshan:fix/shell-path-spaces-11259
Feb 18, 2026
Merged

mstv merged 2 commits into
gitextensions:masterfrom
apoorvdarshan:fix/shell-path-spaces-11259

Conversation

@apoorvdarshan

Copy link
Copy Markdown
Contributor

Summary

  • Add null/empty guards in PathUtil.TryFindShellPath to prevent Path.Combine from throwing or producing invalid paths when ProgramW6432 env var is null or AppSettings.LinuxToolsDir is empty (both common when the Windows username contains spaces, e.g. "Acker Liu")
  • Add unit tests for TryFindShellPath null-safety and Quote/QuoteNE with space-containing paths
  • Add shell command quoting tests verifying GetChangeDirCommand and ExecutableCommandLine patterns produce correctly quoted output for paths with spaces

Fixes #11259

Test plan

  • Run dotnet test --filter PathUtilTest — new tests pass, existing tests unaffected
  • Run dotnet test --filter ShellTests — new shell quoting tests pass
  • Manually verify console launch with a Windows user account containing spaces in the username

…es with spaces (gitextensions#11259)

GetEnvironmentVariable("ProgramW6432") can return null and
AppSettings.LinuxToolsDir defaults to "", both causing Path.Combine to
produce invalid paths. Add null/empty checks before each lookup and
add test coverage for path quoting with spaces.

@mstv mstv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Could you add your sign-off to contributors.txt, please?

Comment thread tests/app/UnitTests/GitUI.Tests/Shells/ShellTests.cs Outdated
@apoorvdarshan

Copy link
Copy Markdown
Contributor Author

Thanks @mstv! Added the UTF-8 BOM to ShellTests.cs and signed contributors.txt in 2fb208c.

@apoorvdarshan
apoorvdarshan requested a review from mstv February 18, 2026 21:02
@sonarqubecloud

Copy link
Copy Markdown

@mstv
mstv merged commit cbc0643 into gitextensions:master Feb 18, 2026
5 checks passed
@mstv mstv added this to the v7.0.0 milestone Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can not launch console while windows username have space

4 participants