Skip to content

Avoid running git upload pack through shell#2060

Draft
dscho wants to merge 3 commits intogitgitgadget:masterfrom
dscho:avoid-running-git-upload-pack-through-shell
Draft

Avoid running git upload pack through shell#2060
dscho wants to merge 3 commits intogitgitgadget:masterfrom
dscho:avoid-running-git-upload-pack-through-shell

Conversation

@dscho
Copy link
Member

@dscho dscho commented Mar 3, 2026

Draft: I still have to consider whether the many changes required in the test suite are indicative of a serious backwards-compatibility problem.

dscho added 3 commits January 7, 2026 00:15
On Windows, file:// URLs need to have Windows paths. In Git's test
suite, however, by virtue of being implemented in shell and using
the Unix paths that are so conveniently converted to Windows behind
the scenes by the POSIX emulation layer required to run the shell,
quite often file:// URLs are used that use _Unix_ paths.

Now, `git upload-pack` is a Windows program in Git for Windows, and has
not the first idea what do do about Unix paths. The only reason why
those incorrect file:// URLs still "work" in the test suite is that
Git insists on calling `git upload-pack` through a shell, even if the
complexity of the command-line `git-upload-pack <path>` does not
warrant the penalty. And that shell, again by virtue of using that
POSIX emulation layer, automagically converts that incorrect Unix path
to a Windows one.

However, it is incorrect to use file:// URLs with incorrect paths.
Therefore, let's just fix those URLs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
There is logic hidden deep inside `run-command.c` that determines
whether a given command _actually_ needs to be run through shell (for
example, if `git-upload-pack` is the program name, it does not need the
shell at all). Extract this useful functionality into its own function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When the `git-upload-pack` program needs to be called, we do not
actually need to run this through a shell... This reduces the security
surface of running Git on servers a bit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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.

1 participant