Skip to content

fix: run Git for Windows sh shim in POSIX mode - #2820

Merged
Sebastian Thiel (Byron) merged 2 commits into
mainfrom
agent/fix-windows-shell-posix-mode
Jul 25, 2026
Merged

fix: run Git for Windows sh shim in POSIX mode#2820
Sebastian Thiel (Byron) merged 2 commits into
mainfrom
agent/fix-windows-shell-posix-mode

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Jul 24, 2026

Copy link
Copy Markdown
Member

Tasks

  • refackiew

Everything below this line is Codex


What changed

  • retain whether gix_path::env::shell() selected Git for Windows' bin/sh.exe shim
  • add gix_path::env::shell_command() to configure that shim with --posix
  • use the configured default shell command from gix-command while leaving with_shell_program() unchanged
  • add a Windows regression test that verifies Bash has POSIX mode enabled

Why

Git for Windows' bin/sh.exe shim delegates to bash.exe. Unlike the non-shim
usr/bin/sh.exe, that starts Bash without POSIX mode, so shell commands run by
gix-command behave differently from shell commands run by Git.

The POSIX option is applied only when the known Git for Windows shim was selected.
Fallback shells and caller-provided shell programs do not receive the Bash-specific
option.

Fixes #1868.

Validation

  • cargo test -p gix-command
  • cargo test -p gix-path -- --test-threads=1
  • cargo clippy -p gix-path -p gix-command --lib -- -D warnings
  • cargo fmt --all -- --check
  • cargo doc -p gix-path --no-deps

@EliahKagan

Eliah Kagan (EliahKagan) commented Jul 24, 2026

Copy link
Copy Markdown
Member

I'm trying to remember why we didn't just go with passing --posix before (under the relevant conditions). I think there was some reason discussed for not moving forward with it, but I don't know if that reason still applies, and maybe it was just that I didn't have time to make the change at that time. If nothing about that can be found on the issue and its comments then this approach is probably okay. I can look at this in a couple days, but I don't think there's any need to wait if the comment discussion has been examined.

@Byron

Copy link
Copy Markdown
Member Author

Thanks for sharing! While somehow I lost the context of the agent that performed this work, I just asked again to see if the comments in the issue materially affect this implementation: short answer is No.

Codex

No material correctness issue found. The issue comments support the branch’s approach:

One non-material residual edge remains: fallback sh.exe instances that cannot be identified as the Git-for-Windows shim receive no --posix. Applying it indiscriminately would break non-Bash shells, so the branch’s conservative behavior is correct.

Relevant crate tests, formatting, and git diff --check pass. The Windows-only regression test exists but could not run on this macOS host. No changes made.

@Byron
Sebastian Thiel (Byron) force-pushed the agent/fix-windows-shell-posix-mode branch from f2565d1 to 6f27275 Compare July 25, 2026 17:38
@Byron
Sebastian Thiel (Byron) marked this pull request as ready for review July 25, 2026 17:39

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f27275e3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread gix-path/src/env/mod.rs
Assisted-by: GPT 5.6
Co-authored-by: GPT 5.6 <codex@openai.com>
<!-- agent -->

Construct default shell invocations with gix_path::env::shell_command()
instead of rebuilding a Command from shell(). This preserves platform-specific
arguments, notably --posix for the Git for Windows bin/sh.exe shim, while
leaving caller-provided shells unchanged.

Assisted-by: GPT 5.6
Co-authored-by: GPT 5.6 <codex@openai.com>
@Byron
Sebastian Thiel (Byron) force-pushed the agent/fix-windows-shell-posix-mode branch from da0903a to 85f10fc Compare July 25, 2026 19:46
@Byron
Sebastian Thiel (Byron) merged commit 5a88ee7 into main Jul 25, 2026
32 checks passed
@Byron
Sebastian Thiel (Byron) deleted the agent/fix-windows-shell-posix-mode branch July 25, 2026 20:05
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.

gix-command on Windows runs shell commands in non-POSIX mode

2 participants