Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project: launch subprocesses without shell #783

Closed
wants to merge 1 commit into from

Conversation

jhol
Copy link

@jhol jhol commented Feb 26, 2025

In the Project method set_new_manifest_rev, the _update_manifest_rev helper function tries to run the following git command:

git update-ref -m .. refs/heads/ref <commit-id>^{commit}

However, on Msys2's MinGW build of python handles the escaping of ...^{commit} incorrectly, converting it into ...commit.

This issue highlights the pitfalls of using the Python subprocess module's shell=True option, which can apply string conversions to commands that are unexpected by the calling code.

In the Project method set_new_manifest_rev, the _update_manifest_rev
helper function tries to run the following git command:

  git update-ref -m .. refs/heads/ref <commit-id>^{commit}

However, on Msys2's MinGW build of python handles the escaping of
"...^{commit}" incorrectly, converting it into "...commit".

This issue highlights the pitfalls of using the Python subprocess
module's shell=True option, which can apply string conversions to
commands that are unexpected by the calling code.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
@jhol jhol marked this pull request as draft February 26, 2025 22:32
@jhol jhol closed this Feb 26, 2025
@marc-hb
Copy link
Collaborator

marc-hb commented Feb 26, 2025

I agree shell=True is evil. As I'm guessing you discovered, some tests depend on it. Maybe some features even?

If you don't have time for a complete fix, could you please turn this into a new bug? I could be wrong but I don't remember this being already filed.

@jhol
Copy link
Author

jhol commented Feb 27, 2025

I misunderstood the problem hence why I closed the PR.

I am experimenting with packaging West for MSys2 MINGW-packages, however there is an impedance mismatch between West built for MinGW Python (native Windows), and Git which is currently only available as the Cygwin/MSys2 version (simulated UNIX). The issues are explained in more detail here.

The question is what to do about it. Installing Git4Windows into MSys2 MinGW is one possible solution.

Another thought that crossed my mind was to replace invocation of the Git executable with a Python Git library e.g. pygit2 , but I don't know if there is a Python Git library that is capable of all the requirements of West e.g. rebasing.

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.

2 participants