git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Steven Penny <svnpenn@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Change Native Windows shell
Date: Fri, 5 Jun 2020 00:00:39 +0000	[thread overview]
Message-ID: <20200605000039.GB6569@camp.crustytoothpaste.net> (raw)
In-Reply-To: <CAAXzdLXt4+-34+OhS=Jn=-VeORN3Y2jMzzg9+bhyn88aN4hm0A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2320 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2020-06-05  0:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 23:33 Change Native Windows shell Steven Penny
2020-06-05  0:00 ` brian m. carlson [this message]
2020-06-05  4:21   ` Steven Penny
2020-06-05  4:39     ` Jonathan Nieder
2020-06-08 17:39     ` Johannes Schindelin
2020-06-08 23:14       ` Steven Penny
2020-06-09  6:12         ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200605000039.GB6569@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=svnpenn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).