Thread (7 messages) 7 messages, 4 authors, 2020-06-09

Re: Change Native Windows shell

From: brian m. carlson <hidden>
Date: 2020-06-05 00:01:39

On 2020-06-04 at 23:33:16, Steven Penny wrote:
The Git pager is set up by the function `setup_pager` [1]. `setup_pager` calls
`prepare_pager_args` [2]. `prepare_pager_args` sets `use_shell` [3]. Then
`setup_pager` calls `start_command` [4]. Then, since `use_shell` has been
defined, `prepare_shell_cmd` is called [5]. Finally, regardless of operating
system, `sh` is called [6]:

    #ifndef GIT_WINDOWS_NATIVE
                    argv_array_push(out, SHELL_PATH);
    #else
                    argv_array_push(out, "sh");
    #endif
                    argv_array_push(out, "-c");

The issue is, that it is possible to build a fully static native Windows
Git [7]. A Git like this can run on a stock Windows system, with no requirement
on MSYS2 or Cygwin. So it doesnt make sense for Git to be calling `sh`, when a
user may not have or need `sh` on their system. I think that on Native Windows
builds, that the Pager should be called directly, or if a shell must be used,
then make it `cmd.exe` or `powershell.exe`.
This makes it impossible to write a configuration that works across
platforms.  CMD, PowerShell, and sh have entirely different quoting
rules and functionality.  The user would not be able to specify a pager
or editor with arguments portably.

In addition, Git supports the EDITOR and VISUAL environment variables
for editors and these always, 100% of the time, must be passed to sh to
function correctly.  It would be a bug if, when I used Windows, these
variables were passed to CMD or PowerShell.  People also use GIT_EDITOR
or GIT_SEQUENCE_EDITOR for scripting changes to git rebase -i, and these
also need to be interpreted in a portable way across systems, or
programs will break.

Finally, Git needs sh for some commands, like git submodule, git bisect,
git filter-branch, and others.  While there's an effort to replace a lot
of these with C because they don't perform very well on Windows, some of
them are highly interactive and unlikely to be used for scripting, so
porting them doesn't make a lot of sense.

If you really need Git functionality that doesn't rely on sh, you can
look into libgit2 and its assorted language wrappers.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help