Re: [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper"
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 12, 2026, 07:51 UTC
- Message-ID
- <bacfe6f4-706e-670c-3466-ccb4d7caeffb@gmx.de>
- In-Reply-To
- <xmqq33wrkvmu.fsf@gitster.g>
Hi Junio,
On Thu, 6 Aug 2026, Junio C Hamano wrote:
Show 16 quoted lines
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > @@ -3186,6 +3225,32 @@ static void setup_windows_environment(void)
> > setenv("HOME", tmp, 1);
> > }
> >
> > + if (!getenv("PLINK_PROTOCOL"))
> > + setenv("PLINK_PROTOCOL", "ssh", 0);
> > +
> > +#ifdef ENSURE_MSYSTEM_IS_SET
> > + if (!(tmp = getenv("MSYSTEM")) || !tmp[0]) {
>
> Checking tmp[0] is a sign that we do not consider MSYSTEM set to an
> empty string a sane state and ENSURE_MSYSTEM_IS_SET is about
> correcting it, right?"sane state" is quite the strong wording for such a minor issue.
The MSYSTEM variable is useful as an indicator, and is therefore used in many scripts. Git itself only uses it as a tell-tale that a GUI should be used in `git bisect visualize`, otherwise Git is totally fine with empty or even non-sensical values.
But it _is_ a convenient thing to have, together with `MINGW_PREFIX` to ensure that the respective `/*/bin/` directories are prepended to the `PATH` variable. That's what this is all about.
Show 14 quoted lines
>
> > + const char *home = getenv("HOME"), *path = getenv("PATH");
> > + char buf[32768];
> > + size_t off = 0;
> > +
> > + setenv("MSYSTEM", ENSURE_MSYSTEM_IS_SET, 1);
>
> In config.mak.uname, ENSURE_MSYSTEM_IS_SET is defined to "$(MSYSTEM)".
>
> + COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY \
> + -DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" \
>
> Can $(MSYSTEM) be an empty string or undefined at the build time,
> making ENSURE_MSYSTEM_IS_SET set to "" (two double-quotes)?Sure it can. Just like `PATH` or `HOME` can be empty, or invalid. But the person building the project has to go out of their way to make it so, therefore I don't want to spend any more brain cells on that highly unlikely scenario.
Ciao, Johannes
Show 14 quoted lines
> Which would mean we are exporting MSYSTEM defined to be an empty string > as well with this setenv. > > It seems ifeq($(uname_S),MINGW) side protects against this situation > by placing the cflags definition > > + COMPAT_CFLAGS += -DDETECT_MSYS_TTY \ > + -DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" \ > > inside "ifneq (,$(MSYSTEM))..endif". That way, ENSURE_MSYSTEM_IS_SET > is not defined to "" (two double-quotes), so #ifdef ENSURE_MSYSTEM_IS_SET > would not kick in. > >