From: Junio C Hamano <gitster@pobox•com>
To: Johannes Schindelin <Johannes.Schindelin@gmx•de>
Cc: git@vger•kernel.org
Subject: Re: [PATCH 1/1] mingw: work around t2300's assuming non-Windows paths
Date: Wed, 22 Jun 2016 09:42:34 -0700 [thread overview]
Message-ID: <xmqqa8idnpj9.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1606220927350.10382@virtualbox> (Johannes Schindelin's message of "Wed, 22 Jun 2016 10:25:31 +0200 (CEST)")
Johannes Schindelin <Johannes.Schindelin@gmx•de> writes:
> On Tue, 21 Jun 2016, Junio C Hamano wrote:
>
>> I said $PATH because --exec-path does not care what you do with
>> %PATH% but it deeply cares that its output is usable in $PATH.
>
> The really, really, really important part to keep in mind is that there is
> no $PATH on Windows.
I think I know that well enough; please sanity check. My
understanding is:
* Your (emulated) getenv(3) reads %PATH% which may look like
"c:\a\b;c:\c\d", i.e. Windows style.
* Your argv_exec_path also looks like "c:\e\f", i.e. Windows
style.
* Your setup_path() would yield "c:\e\f;c:\a\b;c:\c\d" because it
concatenates the above two with PATH_SEP, i.e. Windows style, and
your setenv(3) will set that to %PATH%.
* After all that happens, your run_command(), execv_git_cmd(),
etc. would honor that %PATH%.
* In all of the above, a back-slash can be (and may indeed be) a
forward-slash, as library functions and system calls are prepared
to take both since the good old DOS days. I.e. "c:\a\b" can be
"c:/a/b". It cannot be "/c/a/b", however.
* When bash gets spawned (perhaps because a hook is written in that
language, perhaps because child_process.use_shell is set when
executing an alias "!cmd", running a pager, or running an
editor), the value of %PATH% derived by the above sequence is not
exposed as $PATH. There is the "rewrite leading C: with /C/"
outside us (i.e. in bash).
And that is why I suggested to keep that "internal paths are in
platform native format" and apply the same conversion as what bash
does immediately before the returned value from git_exec_path() is
fed to puts(). That way, "$PATH" (not %PATH%) can be modified with
"$(git --exec-path)" in scripts the same way on all the platforms
and you do not have to break people's hooks.
Having said that, I realize that I missed one huge thing to take
into consideration. I assume that you have been shipping Git for
Windows with this "'git --exec-path' gives c:\a\b, not /c/a/b"
feature for a long time, so existing Windows users will be broken if
we "fix" this (which would allow them to use shell scripts their
friends use on other platforms without modification). So from that
point alone, "PATH=$(git --exec-path):$PATH in shell should work on
any platform and "git --exec-path" should be fixed" would not fly.
This simply is too late to fix.
The patch under discussion is the only door left for that test, and
a similar trickery is needed for any end-user scripts used for hooks
and aliases that use 'git --exec-path', if they ever want to be
cross-platform.
So let's take that "if Windows do this" change to t2300 as-is.
next prev parent reply other threads:[~2016-06-22 16:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-18 10:49 [PATCH 0/1] Fix testing of `master` on Windows Johannes Schindelin
2016-06-18 10:49 ` [PATCH 1/1] mingw: work around t2300's assuming non-Windows paths Johannes Schindelin
2016-06-20 19:09 ` Junio C Hamano
2016-06-21 12:01 ` Johannes Schindelin
2016-06-21 17:10 ` Junio C Hamano
2016-06-21 17:27 ` Junio C Hamano
2016-06-22 8:25 ` Johannes Schindelin
2016-06-22 16:42 ` Junio C Hamano [this message]
2016-06-22 20:06 ` Johannes Schindelin
2016-06-22 20:12 ` Junio C Hamano
2016-06-22 21:26 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqa8idnpj9.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=Johannes.Schindelin@gmx$(echo .)de \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox