Git development
 help / color / mirror / Atom feed
* [PATCH 00/12] Upstream some more Git for Windows' patches
@ 2026-08-05 14:26 Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 01/12] mingw: include the Python parts in the build Johannes Schindelin via GitGitGadget
                   ` (11 more replies)
  0 siblings, 12 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

When rebasing a Git for Windows commit to enable Rust in Windows CI, I
noticed just how many of the preceding commits touching adjacent code
haven't been upstreamed yet. This patch series rectifies that.

Johannes Schindelin (12):
  mingw: include the Python parts in the build
  mingw: stop hard-coding `CC = gcc`
  mingw: drop the -D_USE_32BIT_TIME_T option
  mingw: only use -Wl,--large-address-aware for 32-bit builds
  mingw: avoid over-specifying `--pic-executable`
  mingw: set the prefix and HOST_CPU as per MSYS2's settings
  mingw: only enable the MSYS2-specific stuff when compiling in MSYS2
  mingw: rely on MSYS2's metadata instead of hard-coding it
  windows: skip linking `git-<command>` for built-ins
  mingw: always define `ETC_*` for MSYS2 environments
  mingw: ensure valid CTYPE
  mingw: allow `git.exe` to be used instead of the "Git wrapper"

 compat/mingw.c                      | 68 +++++++++++++++++++++++++++++
 config.mak.uname                    | 61 ++++++++++++--------------
 contrib/buildsystems/CMakeLists.txt |  9 +++-
 meson.build                         | 13 +++++-
 meson_options.txt                   |  4 ++
 t/t0060-path-utils.sh               | 33 +++++++++++++-
 6 files changed, 151 insertions(+), 37 deletions(-)


base-commit: 5b2471720c93ee30e5764a19f3d3b3ae9ec9712a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2195%2Fdscho%2Fupstream-some-more-git-for-windows-patches-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2195/dscho/upstream-some-more-git-for-windows-patches-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2195
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 01/12] mingw: include the Python parts in the build
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 02/12] mingw: stop hard-coding `CC = gcc` Johannes Schindelin via GitGitGadget
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

While Git for Windows does not _ship_ Python (in order to save on
bandwidth), MSYS2 provides very fine Python interpreters that users can
easily take advantage of, by using Git for Windows within its SDK.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 1 +
 1 file changed, 1 insertion(+)

diff --git a/config.mak.uname b/config.mak.uname
index 9ebd240378..8dd8acfaa5 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -781,6 +781,7 @@ ifeq ($(uname_S),MINGW)
 	HAVE_LIBCHARSET_H = YesPlease
 	USE_GETTEXT_SCHEME = fallthrough
 	USE_LIBPCRE = YesPlease
+	NO_PYTHON =
         ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
 		# Move system config into top-level /etc/
 		ETC_GITCONFIG = ../etc/gitconfig
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 02/12] mingw: stop hard-coding `CC = gcc`
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 01/12] mingw: include the Python parts in the build Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 03/12] mingw: drop the -D_USE_32BIT_TIME_T option Johannes Schindelin via GitGitGadget
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

This is no longer true in general, not with supporting Clang out of the
box.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config.mak.uname b/config.mak.uname
index 8dd8acfaa5..a464b2009c 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -771,7 +771,6 @@ ifeq ($(uname_S),MINGW)
 		COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
 		BASIC_LDFLAGS += -Wl,--large-address-aware
         endif
-	CC = gcc
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 		-fstack-protector-strong
 	EXTLIBS += -lntdll
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 03/12] mingw: drop the -D_USE_32BIT_TIME_T option
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 01/12] mingw: include the Python parts in the build Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 02/12] mingw: stop hard-coding `CC = gcc` Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 04/12] mingw: only use -Wl,--large-address-aware for 32-bit builds Johannes Schindelin via GitGitGadget
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

This option was added in fa93bb20d72 (MinGW: Fix stat definitions to
work with MinGW runtime version 4.0, 2013-09-11), i.e. a _long_ time
ago. So long, in fact, that it still targeted MinGW. But we switched to
mingw-w64 in 2015, which seems not to share the problem, and therefore
does not require a fix.

Even worse: This flag is incompatible with UCRT64, which we are about to
support by way of upstreaming `mingw-w64-git` to the MSYS2 project, see
https://github.com/msys2/MINGW-packages/pull/26470 for details.

So let's send that option into its well-deserved retirement.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 1 -
 1 file changed, 1 deletion(-)

diff --git a/config.mak.uname b/config.mak.uname
index a464b2009c..cc0ed63af3 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -768,7 +768,6 @@ ifeq ($(uname_S),MINGW)
 		HOST_CPU = aarch64
 		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
         else
-		COMPAT_CFLAGS += -D_USE_32BIT_TIME_T
 		BASIC_LDFLAGS += -Wl,--large-address-aware
         endif
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 04/12] mingw: only use -Wl,--large-address-aware for 32-bit builds
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (2 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 03/12] mingw: drop the -D_USE_32BIT_TIME_T option Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 05/12] mingw: avoid over-specifying `--pic-executable` Johannes Schindelin via GitGitGadget
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

That option only matters there, and is in fact only really understood in
those builds; UCRT64 versions of GCC, for example, do not know what to
do with that option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index cc0ed63af3..b667c693ec 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -757,9 +757,8 @@ ifeq ($(uname_S),MINGW)
         ifeq (MINGW32,$(MSYSTEM))
 		prefix = /mingw32
 		HOST_CPU = i686
-		BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup
-        endif
-        ifeq (MINGW64,$(MSYSTEM))
+		BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup -Wl,--large-address-aware
+        else ifeq (MINGW64,$(MSYSTEM))
 		prefix = /mingw64
 		HOST_CPU = x86_64
 		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
@@ -768,7 +767,6 @@ ifeq ($(uname_S),MINGW)
 		HOST_CPU = aarch64
 		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
         else
-		BASIC_LDFLAGS += -Wl,--large-address-aware
         endif
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 		-fstack-protector-strong
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 05/12] mingw: avoid over-specifying `--pic-executable`
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (3 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 04/12] mingw: only use -Wl,--large-address-aware for 32-bit builds Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 06/12] mingw: set the prefix and HOST_CPU as per MSYS2's settings Johannes Schindelin via GitGitGadget
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

In bf2d5d8239e (Don't let ld strip relocations, 2016-01-16) (picked from
https://github.com/git-for-windows/git/pull/612/commits/6a237925bf10),
Git for Windows introduced the `-Wl,-pic-executable` flag, specifying
the exact entry point via `-e`. This required discerning between i686
and x86_64 code because the former required the symbol to be prefixed
with an underscore, the latter did not.

As per https://sourceware.org/bugzilla/show_bug.cgi?id=10865, the
specified symbols are already the default, though.

So let's drop the overly-specific definition.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index b667c693ec..f6387f4c7b 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -757,15 +757,15 @@ ifeq ($(uname_S),MINGW)
         ifeq (MINGW32,$(MSYSTEM))
 		prefix = /mingw32
 		HOST_CPU = i686
-		BASIC_LDFLAGS += -Wl,--pic-executable,-e,_mainCRTStartup -Wl,--large-address-aware
+		BASIC_LDFLAGS += -Wl,--pic-executable -Wl,--large-address-aware
         else ifeq (MINGW64,$(MSYSTEM))
 		prefix = /mingw64
 		HOST_CPU = x86_64
-		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
+		BASIC_LDFLAGS += -Wl,--pic-executable
         else ifeq (CLANGARM64,$(MSYSTEM))
 		prefix = /clangarm64
 		HOST_CPU = aarch64
-		BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup
+		BASIC_LDFLAGS += -Wl,--pic-executable
         else
         endif
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 06/12] mingw: set the prefix and HOST_CPU as per MSYS2's settings
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (4 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 05/12] mingw: avoid over-specifying `--pic-executable` Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 07/12] mingw: only enable the MSYS2-specific stuff when compiling in MSYS2 Johannes Schindelin via GitGitGadget
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

MSYS2 already defines a couple of helpful environment variables, and we
can use those to infer the installation location as well as the CPU. No
need for hard-coding ;-)

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index f6387f4c7b..8363239513 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -754,19 +754,13 @@ ifeq ($(uname_S),MINGW)
         ifneq (,$(findstring -O,$(filter-out -O0 -Og,$(CFLAGS))))
 		BASIC_LDFLAGS += -Wl,--dynamicbase
         endif
-        ifeq (MINGW32,$(MSYSTEM))
-		prefix = /mingw32
-		HOST_CPU = i686
-		BASIC_LDFLAGS += -Wl,--pic-executable -Wl,--large-address-aware
-        else ifeq (MINGW64,$(MSYSTEM))
-		prefix = /mingw64
-		HOST_CPU = x86_64
-		BASIC_LDFLAGS += -Wl,--pic-executable
-        else ifeq (CLANGARM64,$(MSYSTEM))
-		prefix = /clangarm64
-		HOST_CPU = aarch64
+        ifneq (,$(MSYSTEM))
+		prefix = $(MINGW_PREFIX)
+		HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))
 		BASIC_LDFLAGS += -Wl,--pic-executable
-        else
+                ifeq (MINGW32,$(MSYSTEM))
+			BASIC_LDFLAGS += -Wl,--large-address-aware
+                endif
         endif
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
 		-fstack-protector-strong
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 07/12] mingw: only enable the MSYS2-specific stuff when compiling in MSYS2
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (5 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 06/12] mingw: set the prefix and HOST_CPU as per MSYS2's settings Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it Johannes Schindelin via GitGitGadget
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

The tell-tale is the presence of the `MSYSTEM` value while compiling, of
course. In that case, we want to ensure that `MSYSTEM` is set when
running `git.exe`, and also enable the magic MSYS2 tty detection.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index 8363239513..21f53e3f7e 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -758,12 +758,12 @@ ifeq ($(uname_S),MINGW)
 		prefix = $(MINGW_PREFIX)
 		HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))
 		BASIC_LDFLAGS += -Wl,--pic-executable
+		COMPAT_CFLAGS += -DDETECT_MSYS_TTY
                 ifeq (MINGW32,$(MSYSTEM))
 			BASIC_LDFLAGS += -Wl,--large-address-aware
                 endif
         endif
-	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \
-		-fstack-protector-strong
+	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -fstack-protector-strong
 	EXTLIBS += -lntdll
 	EXTRA_PROGRAMS += headless-git$X
 	INSTALL = /bin/install
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (6 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 07/12] mingw: only enable the MSYS2-specific stuff when compiling in MSYS2 Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 17:29   ` Junio C Hamano
  2026-08-05 14:26 ` [PATCH 09/12] windows: skip linking `git-<command>` for built-ins Johannes Schindelin via GitGitGadget
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

MSYS2 defines some helpful environment variables, e.g. `MSYSTEM`. There
is code in Git for Windows to ensure that that `MSYSTEM` variable is
set, hard-coding a default.

However, the existing solution jumps through hoops to reconstruct the
proper default, and is even incomplete doing so, as we found out when we
extended it to support CLANGARM64.

This is absolutely unnecessary because there is already a perfectly
valid `MSYSTEM` value we can use at build time. This is even true when
building the MINGW32 variant on a MINGW64 system because `makepkg-mingw`
will override the `MSYSTEM` value as per the `MINGW_ARCH` array.

The same is equally true for the `/mingw64`, `/mingw32` and
`/clangarm64` prefix: those values are already available via the
`MINGW_PREFIX` environment variable, and we just need to pass that
setting through.

Only when `MINGW_PREFIX` is not set (as is the case in Git for Windows'
minimal SDK, where only `MSYSTEM` is guaranteed to be set correctly), we
use as fall-back the top-level directory whose name is the down-cased
value of the `MSYSTEM` variable.

Incidentally, this also broadens the support to all the configurations
supported by the MSYS2 project, i.e. clang64 & ucrt64, too.

Note: This keeps the same, hard-coded MSYSTEM platform support for CMake
as before, but drops it for Meson (because it is unclear how Meson could
do this in a more flexible manner).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname                    | 14 ++++++--------
 contrib/buildsystems/CMakeLists.txt |  9 ++++++++-
 meson.build                         | 13 ++++++++++++-
 meson_options.txt                   |  4 ++++
 4 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index 21f53e3f7e..3a90995587 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -465,14 +465,8 @@ ifeq ($(uname_S),Windows)
 	GIT_VERSION := $(GIT_VERSION).MSVC
 	pathsep = ;
 	# Assume that this is built in Git for Windows' SDK
-        ifeq (MINGW32,$(MSYSTEM))
-		prefix = /mingw32
-        else
-                ifeq (CLANGARM64,$(MSYSTEM))
-			prefix = /clangarm64
-                else
-			prefix = /mingw64
-                endif
+        ifneq (,$(MSYSTEM))
+		prefix = $(MINGW_PREFIX)
         endif
 	# Prepend MSVC 64-bit tool-chain to PATH.
 	#
@@ -755,6 +749,10 @@ ifeq ($(uname_S),MINGW)
 		BASIC_LDFLAGS += -Wl,--dynamicbase
         endif
         ifneq (,$(MSYSTEM))
+                ifeq ($(MINGW_PREFIX),$(filter-out /%,$(MINGW_PREFIX)))
+			# Override if empty or does not start with a slash
+			MINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z)
+                endif
 		prefix = $(MINGW_PREFIX)
 		HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))
 		BASIC_LDFLAGS += -Wl,--pic-executable
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index a57c4b464f..7285bd9ac2 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -256,7 +256,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 				_CONSOLE DETECT_MSYS_TTY STRIP_EXTENSION=".exe"  NO_SYMLINK_HEAD UNRELIABLE_FSTAT
 				NOGDI OBJECT_CREATION_MODE=1 __USE_MINGW_ANSI_STDIO=0
 				OVERRIDE_STRDUP MMAP_PREVENTS_DELETE USE_WIN32_MMAP
-				HAVE_WPGMPTR ENSURE_MSYSTEM_IS_SET HAVE_RTLGENRANDOM)
+				HAVE_WPGMPTR HAVE_RTLGENRANDOM)
+	if(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
+		add_compile_definitions(ENSURE_MSYSTEM_IS_SET="MINGW64" MINGW_PREFIX="mingw64")
+	elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "arm64")
+		add_compile_definitions(ENSURE_MSYSTEM_IS_SET="CLANGARM64" MINGW_PREFIX="clangarm64")
+	elseif(CMAKE_GENERATOR_PLATFORM STREQUAL "x86")
+		add_compile_definitions(ENSURE_MSYSTEM_IS_SET="MINGW32" MINGW_PREFIX="mingw32")
+	endif()
 	list(APPEND compat_SOURCES
 		compat/mingw.c
 		compat/winansi.c
diff --git a/meson.build b/meson.build
index 7073d5844d..6ddc461873 100644
--- a/meson.build
+++ b/meson.build
@@ -1318,7 +1318,6 @@ elif host_machine.system() == 'windows'
 
   libgit_c_args += [
     '-DDETECT_MSYS_TTY',
-    '-DENSURE_MSYSTEM_IS_SET',
     '-DNATIVE_CRLF',
     '-DNOGDI',
     '-DNO_POSIX_GOODIES',
@@ -1328,6 +1327,18 @@ elif host_machine.system() == 'windows'
     '-D__USE_MINGW_ANSI_STDIO=0',
   ]
 
+  msystem = get_option('msystem')
+  if msystem != ''
+    mingw_prefix = get_option('mingw_prefix')
+    if mingw_prefix == ''
+      mingw_prefix = '/' + msystem.to_lower()
+    endif
+    libgit_c_args += [
+      '-DENSURE_MSYSTEM_IS_SET="' + msystem + '"',
+      '-DMINGW_PREFIX="' + mingw_prefix + '"'
+    ]
+  endif
+
   libgit_dependencies += compiler.find_library('ntdll')
   libgit_include_directories += 'compat/win32'
   if compiler.get_id() == 'msvc'
diff --git a/meson_options.txt b/meson_options.txt
index dc88f130d7..becf4689bf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -21,6 +21,10 @@ option('runtime_prefix', type: 'boolean', value: false,
   description: 'Resolve ancillary tooling and support files relative to the location of the runtime binary instead of hard-coding them into the binary.')
 option('sane_tool_path', type: 'array', value: [],
   description: 'An array of paths to pick up tools from in case the normal tools are broken or lacking.')
+option('msystem', type: 'string', value: '',
+  description: 'Fall-back on Windows when MSYSTEM is not set.')
+option('mingw_prefix', type: 'string', value: '',
+  description: 'Fall-back on Windows when MINGW_PREFIX is not set.')
 
 # Build information compiled into Git and other parts like documentation.
 option('build_date', type: 'string', value: '',
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 09/12] windows: skip linking `git-<command>` for built-ins
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (7 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 17:12   ` Junio C Hamano
  2026-08-05 14:26 ` [PATCH 10/12] mingw: always define `ETC_*` for MSYS2 environments Johannes Schindelin via GitGitGadget
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

It is merely a historical wart that, say, `git-commit` exists in the
`libexec/git-core/` directory, a tribute to the original idea to let Git
be essentially a bunch of Unix shell scripts revolving around very few
"plumbing" (AKA low-level) commands.

Git has evolved a lot from there. These days, most of Git's
functionality is contained within the `git` executable, in the form of
"built-in" commands.

To accommodate for scripts that use the "dashed" form of Git commands,
even today, Git provides hard-links that make the `git` executable
available as, say, `git-commit`, just in case that an old script has not
been updated to invoke `git commit`.

Those hard-links do not come cheap: they take about half a minute for
every build of Git on Windows, they are mistaken for taking up huge
amounts of space by some Windows Explorer versions that do not
understand hard-links, and therefore many a "bug" report had to be
addressed.

The "dashed form" has been officially deprecated in Git version 1.5.4,
which was released on February 2nd, 2008, i.e. a very long time ago.
This deprecation was never finalized by skipping these hard-links, but
we can start the process now, in Git for Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/config.mak.uname b/config.mak.uname
index 3a90995587..88bbe1d78f 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -518,6 +518,7 @@ ifeq ($(uname_S),Windows)
 	NO_POSIX_GOODIES = UnfortunatelyYes
 	NATIVE_CRLF = YesPlease
 	DEFAULT_HELP_FORMAT = html
+	SKIP_DASHED_BUILT_INS = YabbaDabbaDoo
 ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
 	# Move system config into top-level /etc/
 	ETC_GITCONFIG = ../etc/gitconfig
@@ -710,6 +711,7 @@ ifeq ($(uname_S),MINGW)
 	FSMONITOR_DAEMON_BACKEND = win32
 	FSMONITOR_OS_SETTINGS = win32
 
+	SKIP_DASHED_BUILT_INS = YabbaDabbaDoo
 	RUNTIME_PREFIX = YesPlease
 	HAVE_WPGMPTR = YesWeDo
 	NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 10/12] mingw: always define `ETC_*` for MSYS2 environments
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (8 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 09/12] windows: skip linking `git-<command>` for built-ins Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 11/12] mingw: ensure valid CTYPE Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper" Johannes Schindelin via GitGitGadget
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Special-casing even more configurations simply does not make sense.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 config.mak.uname | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/config.mak.uname b/config.mak.uname
index 88bbe1d78f..2f7d445eb3 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -519,7 +519,7 @@ ifeq ($(uname_S),Windows)
 	NATIVE_CRLF = YesPlease
 	DEFAULT_HELP_FORMAT = html
 	SKIP_DASHED_BUILT_INS = YabbaDabbaDoo
-ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
+ifneq (,$(MINGW_PREFIX))
 	# Move system config into top-level /etc/
 	ETC_GITCONFIG = ../etc/gitconfig
 	ETC_GITATTRIBUTES = ../etc/gitattributes
@@ -762,6 +762,9 @@ ifeq ($(uname_S),MINGW)
                 ifeq (MINGW32,$(MSYSTEM))
 			BASIC_LDFLAGS += -Wl,--large-address-aware
                 endif
+		# Move system config into top-level /etc/
+		ETC_GITCONFIG = ../etc/gitconfig
+		ETC_GITATTRIBUTES = ../etc/gitattributes
         endif
 	COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -fstack-protector-strong
 	EXTLIBS += -lntdll
@@ -772,11 +775,6 @@ ifeq ($(uname_S),MINGW)
 	USE_GETTEXT_SCHEME = fallthrough
 	USE_LIBPCRE = YesPlease
 	NO_PYTHON =
-        ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix))))
-		# Move system config into top-level /etc/
-		ETC_GITCONFIG = ../etc/gitconfig
-		ETC_GITATTRIBUTES = ../etc/gitattributes
-        endif
 endif
 ifeq ($(uname_S),QNX)
 	COMPAT_CFLAGS += -DSA_RESTART=0
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 11/12] mingw: ensure valid CTYPE
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (9 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 10/12] mingw: always define `ETC_*` for MSYS2 environments Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-05 14:26 ` [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper" Johannes Schindelin via GitGitGadget
  11 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

A change between versions 2.4.1 and 2.6.0 of the MSYS2 runtime modified
how Cygwin's runtime (and hence Git for Windows' MSYS2 runtime
derivative) handles locales: d16a56306d (Consolidate wctomb/mbtowc calls
for POSIX-1.2008, 2016-07-20).

An unintended side-effect is that "cold-calling" into the POSIX
emulation will start with a locale based on the current code page,
something that Git for Windows is very ill-prepared for, as it expects
to be able to pass a command-line containing non-ASCII characters to the
shell without having those characters munged.

One symptom of this behavior: when `git clone` or `git fetch` shell out
to call `git-upload-pack` with a path that contains non-ASCII
characters, the shell tried to interpret the entire command-line
(including command-line parameters) as executable path, which obviously
must fail.

This fixes https://github.com/git-for-windows/git/issues/1036

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compat/mingw.c b/compat/mingw.c
index e0fbd2c66d..afdc1ef2db 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -3185,6 +3185,9 @@ static void setup_windows_environment(void)
 		if (!tmp && (tmp = getenv("USERPROFILE")))
 			setenv("HOME", tmp, 1);
 	}
+
+	if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG"))
+		setenv("LC_CTYPE", "C.UTF-8", 1);
 }
 
 int mingw_platform_has_symlinks(void)
-- 
gitgitgadget


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper"
  2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
                   ` (10 preceding siblings ...)
  2026-08-05 14:26 ` [PATCH 11/12] mingw: ensure valid CTYPE Johannes Schindelin via GitGitGadget
@ 2026-08-05 14:26 ` Johannes Schindelin via GitGitGadget
  2026-08-06 17:26   ` Junio C Hamano
  11 siblings, 1 reply; 17+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2026-08-05 14:26 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Git for Windows wants to add `git.exe` to the users' `PATH`, without
cluttering the latter with unnecessary executables such as `wish.exe`.
To that end, it invented the concept of its "Git wrapper", i.e. a tiny
executable located in `C:\Program Files\Git\cmd\git.exe` (originally a
CMD script) whose sole purpose is to set up a couple of environment
variables and then spawn the _actual_ `git.exe` (which nowadays lives in
`C:\Program Files\Git\mingw64\bin\git.exe` for 64-bit, and the obvious
equivalent for 32-bit installations).

Currently, the following environment variables are set unless already
initialized:

- `MSYSTEM`, to make sure that the MSYS2 Bash and the MSYS2 Perl
  interpreter behave as expected, and

- `PLINK_PROTOCOL`, to force PuTTY's `plink.exe` to use the SSH
  protocol instead of Telnet,

- `PATH`, to make sure that the `bin` folder in the user's home
  directory, as well as the `/mingw64/bin` and the `/usr/bin`
  directories are included. The trick here is that the `/mingw64/bin/`
  and `/usr/bin/` directories are relative to the top-level installation
  directory of Git for Windows (which the included Bash interprets as
  `/`, i.e. as the MSYS pseudo root directory).

Using the absence of `MSYSTEM` as a tell-tale, we can detect in
`git.exe` whether these environment variables have been initialized
properly. Therefore we can call `C:\Program Files\Git\mingw64\bin\git`
in-place after this change, without having to call Git through the Git
wrapper.

Obviously, above-mentioned directories must be _prepended_ to the `PATH`
variable, otherwise we risk picking up executables from unrelated Git
installations. We do that by constructing the new `PATH` value from
scratch, appending `$HOME/bin` (if `HOME` is set), then the MSYS2 system
directories, and then appending the original `PATH`.

Side note: this modification of the `PATH` variable is independent of
the modification necessary to reach the executables and scripts in
`/mingw64/libexec/git-core/`, i.e. the `GIT_EXEC_PATH`. That
modification is still performed by Git, elsewhere, long after making the
changes described above.

While we _still_ cannot simply hard-link `mingw64\bin\git.exe` to `cmd`
(because the former depends on a couple of `.dll` files that are only in
`mingw64\bin`, i.e. calling `...\cmd\git.exe` would fail to load due to
missing dependencies), at least we can now avoid that extra process of
running the Git wrapper (which then has to wait for the spawned
`git.exe` to finish) by calling `...\mingw64\bin\git.exe` directly, via
its absolute path.

Testing this is in Git's test suite tricky: we set up a "new" MSYS
pseudo-root and copy the `git.exe` file into the appropriate location,
then verify that `MSYSTEM` is set properly, and also that the `PATH` is
modified so that scripts can be found in `$HOME/bin`, `/mingw64/bin/`
and `/usr/bin/`.

This addresses https://github.com/git-for-windows/git/issues/2283

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.c        | 65 +++++++++++++++++++++++++++++++++++++++++++
 config.mak.uname      |  8 ++++--
 t/t0060-path-utils.sh | 33 +++++++++++++++++++++-
 3 files changed, 103 insertions(+), 3 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index afdc1ef2db..563e6299bc 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -3134,6 +3134,45 @@ int xwcstoutf(char *utf, const wchar_t *wcs, size_t utflen)
 	return -1;
 }
 
+#ifdef ENSURE_MSYSTEM_IS_SET
+#if !defined(RUNTIME_PREFIX) || !defined(HAVE_WPGMPTR) || !defined(MINGW_PREFIX)
+static size_t append_system_bin_dirs(char *path UNUSED, size_t size UNUSED)
+{
+	return 0;
+}
+#else
+static size_t append_system_bin_dirs(char *path, size_t size)
+{
+	char prefix[32768];
+	const char *slash;
+	size_t len = xwcstoutf(prefix, _wpgmptr, sizeof(prefix)), off = 0;
+
+	if (len == 0 || len >= sizeof(prefix) ||
+	    !(slash = find_last_dir_sep(prefix)))
+		return 0;
+	/* strip trailing `git.exe` */
+	len = slash - prefix;
+
+	/* strip trailing `cmd` or `<mingw-prefix>\bin` or `bin` or `libexec\git-core` */
+	if (strip_suffix_mem(prefix, &len, "\\" MINGW_PREFIX "\\libexec\\git-core") ||
+	    strip_suffix_mem(prefix, &len, "\\" MINGW_PREFIX "\\bin"))
+		off += xsnprintf(path + off, size - off,
+				 "%.*s\\" MINGW_PREFIX "\\bin;", (int)len, prefix);
+	else if (strip_suffix_mem(prefix, &len, "\\cmd") ||
+		 strip_suffix_mem(prefix, &len, "\\bin") ||
+		 strip_suffix_mem(prefix, &len, "\\libexec\\git-core"))
+		off += xsnprintf(path + off, size - off,
+				 "%.*s\\" MINGW_PREFIX "\\bin;", (int)len, prefix);
+	else
+		return 0;
+
+	off += xsnprintf(path + off, size - off,
+			 "%.*s\\usr\\bin;", (int)len, prefix);
+	return off;
+}
+#endif
+#endif
+
 static void setup_windows_environment(void)
 {
 	char *tmp = getenv("TMPDIR");
@@ -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]) {
+		const char *home = getenv("HOME"), *path = getenv("PATH");
+		char buf[32768];
+		size_t off = 0;
+
+		setenv("MSYSTEM", ENSURE_MSYSTEM_IS_SET, 1);
+
+		if (home)
+			off += xsnprintf(buf + off, sizeof(buf) - off,
+					 "%s\\bin;", home);
+		off += append_system_bin_dirs(buf + off, sizeof(buf) - off);
+		if (path)
+			off += xsnprintf(buf + off, sizeof(buf) - off,
+					 "%s", path);
+		else if (off > 0)
+			buf[off - 1] = '\0';
+		else
+			buf[0] = '\0';
+		setenv("PATH", buf, 1);
+	}
+#endif
+
 	if (!getenv("LC_ALL") && !getenv("LC_CTYPE") && !getenv("LANG"))
 		setenv("LC_CTYPE", "C.UTF-8", 1);
 }
diff --git a/config.mak.uname b/config.mak.uname
index 2f7d445eb3..0b63be10b7 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -535,7 +535,9 @@ endif
 		compat/win32/pthread.o compat/win32/syslog.o \
 		compat/win32/trace2_win32_process_info.o \
 		compat/win32/dirent.o
-	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
+	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY \
+		-DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" \
+		-DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
 	BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
 	# invalidcontinue.obj allows Git's source code to close the same file
 	# handle twice, or to access the osfhandle of an already-closed stdout
@@ -758,7 +760,9 @@ ifeq ($(uname_S),MINGW)
 		prefix = $(MINGW_PREFIX)
 		HOST_CPU = $(patsubst %-w64-mingw32,%,$(MINGW_CHOST))
 		BASIC_LDFLAGS += -Wl,--pic-executable
-		COMPAT_CFLAGS += -DDETECT_MSYS_TTY
+		COMPAT_CFLAGS += -DDETECT_MSYS_TTY \
+			-DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" \
+			-DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\""
                 ifeq (MINGW32,$(MSYSTEM))
 			BASIC_LDFLAGS += -Wl,--large-address-aware
                 endif
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 8545cdfab5..56faf5fe73 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -602,7 +602,8 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD 'RUNTIME_PREFIX wor
 	echo "echo HERE" | write_script pretend/libexec/git-core/git-here &&
 	GIT_EXEC_PATH= ./pretend/bin/git here >actual &&
 	echo HERE >expect &&
-	test_cmp expect actual'
+	test_cmp expect actual
+'
 
 test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works' '
 	git config yes.path "%(prefix)/yes" &&
@@ -611,4 +612,34 @@ test_expect_success !VALGRIND,RUNTIME_PREFIX,CAN_EXEC_IN_PWD '%(prefix)/ works'
 	test_cmp expect actual
 '
 
+test_expect_success MINGW,RUNTIME_PREFIX 'MSYSTEM/PATH is adjusted if necessary' '
+	if test -z "$MINGW_PREFIX"
+	then
+		MINGW_PREFIX="/$(echo "${MSYSTEM:-MINGW64}" | tr A-Z a-z)"
+	fi &&
+	mkdir -p "$HOME"/bin pretend"$MINGW_PREFIX"/bin \
+		pretend"$MINGW_PREFIX"/libexec/git-core pretend/usr/bin &&
+	cp "$GIT_EXEC_PATH"/git.exe pretend"$MINGW_PREFIX"/bin/ &&
+	cp "$GIT_EXEC_PATH"/git.exe pretend"$MINGW_PREFIX"/libexec/git-core/ &&
+	# copy the .dll files, if any (happens when building via CMake)
+	if test -n "$(ls "$GIT_EXEC_PATH"/*.dll 2>/dev/null)"
+	then
+		cp "$GIT_EXEC_PATH"/*.dll pretend"$MINGW_PREFIX"/bin/ &&
+		cp "$GIT_EXEC_PATH"/*.dll pretend"$MINGW_PREFIX"/libexec/git-core/
+	fi &&
+	echo "env | grep MSYSTEM=" | write_script "$HOME"/bin/git-test-home &&
+	echo "echo ${MINGW_PREFIX#/}" | write_script pretend"$MINGW_PREFIX"/bin/git-test-bin &&
+	echo "echo usr" | write_script pretend/usr/bin/git-test-bin2 &&
+
+	(
+		MSYSTEM= &&
+		GIT_EXEC_PATH= &&
+		pretend"$MINGW_PREFIX"/libexec/git-core/git.exe test-home >actual &&
+		pretend"$MINGW_PREFIX"/libexec/git-core/git.exe test-bin >>actual &&
+		pretend"$MINGW_PREFIX"/bin/git.exe test-bin2 >>actual
+	) &&
+	test_write_lines MSYSTEM=$MSYSTEM "${MINGW_PREFIX#/}" usr >expect &&
+	test_cmp expect actual
+'
+
 test_done
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 09/12] windows: skip linking `git-<command>` for built-ins
  2026-08-05 14:26 ` [PATCH 09/12] windows: skip linking `git-<command>` for built-ins Johannes Schindelin via GitGitGadget
@ 2026-08-05 17:12   ` Junio C Hamano
  0 siblings, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2026-08-05 17:12 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> The "dashed form" has been officially deprecated in Git version 1.5.4,
> which was released on February 2nd, 2008, i.e. a very long time ago.
> This deprecation was never finalized by skipping these hard-links, but
> we can start the process now, in Git for Windows.

Good.  Perhaps somebody (you do not have to volunteer) can champion
their removal from everywhere at Git 3.0 version boundary?

Thanks.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it
  2026-08-05 14:26 ` [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it Johannes Schindelin via GitGitGadget
@ 2026-08-05 17:29   ` Junio C Hamano
  2026-08-06 12:50     ` Johannes Schindelin
  0 siblings, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2026-08-05 17:29 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> -                ifeq (CLANGARM64,$(MSYSTEM))
> -			prefix = /clangarm64
> -                else
> -			prefix = /mingw64
> -                endif
> +        ifneq (,$(MSYSTEM))
> +		prefix = $(MINGW_PREFIX)
>          endif

Mental note: if $(MSYSTEM) is not an empty string, we set prefix to
$(MINGW_PREFIX).

> @@ -755,6 +749,10 @@ ifeq ($(uname_S),MINGW)
>  		BASIC_LDFLAGS += -Wl,--dynamicbase
>          endif
>          ifneq (,$(MSYSTEM))
> +                ifeq ($(MINGW_PREFIX),$(filter-out /%,$(MINGW_PREFIX)))
> +			# Override if empty or does not start with a slash
> +			MINGW_PREFIX := /$(shell echo '$(MSYSTEM)' | tr A-Z a-z)
> +                endif

Mental note: MINGW_PREFIX that does not begin with a slash is forced
to begin with a slash.

>  		prefix = $(MINGW_PREFIX)

And that becomes $(prefix).

> diff --git a/meson.build b/meson.build
> index 7073d5844d..6ddc461873 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1318,7 +1318,6 @@ elif host_machine.system() == 'windows'
>  
>    libgit_c_args += [
>      '-DDETECT_MSYS_TTY',
> -    '-DENSURE_MSYSTEM_IS_SET',
>      '-DNATIVE_CRLF',
>      '-DNOGDI',
>      '-DNO_POSIX_GOODIES',
> @@ -1328,6 +1327,18 @@ elif host_machine.system() == 'windows'
>      '-D__USE_MINGW_ANSI_STDIO=0',
>    ]
>  
> +  msystem = get_option('msystem')
> +  if msystem != ''
> +    mingw_prefix = get_option('mingw_prefix')
> +    if mingw_prefix == ''
> +      mingw_prefix = '/' + msystem.to_lower()
> +    endif
> +    libgit_c_args += [
> +      '-DENSURE_MSYSTEM_IS_SET="' + msystem + '"',
> +      '-DMINGW_PREFIX="' + mingw_prefix + '"'
> +    ]
> +  endif

Lowercase mingw_prefix in Meson world corresponds to MINGW_PREFIX in
Make world, I guess.  -DMINGW_PRFIX gets mingw_prefix which begins
with a slash.

I do not do Windows or Meson, but doesn't this contradict with what
we have in [12/12], part of which says:

diff --git a/config.mak.uname b/config.mak.uname
index 2f7d445eb3..0b63be10b7 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -535,7 +535,9 @@ endif
 		compat/win32/pthread.o compat/win32/syslog.o \
 		compat/win32/trace2_win32_process_info.o \
 		compat/win32/dirent.o
-	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
+	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY \
+		-DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" \
+		-DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
 	BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
 	# invalidcontinue.obj allows Git's source code to close the same file
 	# handle twice, or to access the osfhandle of an already-closed stdout


IOW, -DMINGW_PREFIX passed to the compiler strips leading slash from
$(MINGW_PREFIX).

Isn't it necessary to strip the leading slash from ming_prefix also
on the Meson side?

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it
  2026-08-05 17:29   ` Junio C Hamano
@ 2026-08-06 12:50     ` Johannes Schindelin
  0 siblings, 0 replies; 17+ messages in thread
From: Johannes Schindelin @ 2026-08-06 12:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin via GitGitGadget, git

Hi Junio,

On Wed, 5 Aug 2026, Junio C Hamano wrote:

> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
> [...]
> > diff --git a/meson.build b/meson.build
> > index 7073d5844d..6ddc461873 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -1318,7 +1318,6 @@ elif host_machine.system() == 'windows'
> >  
> >    libgit_c_args += [
> >      '-DDETECT_MSYS_TTY',
> > -    '-DENSURE_MSYSTEM_IS_SET',
> >      '-DNATIVE_CRLF',
> >      '-DNOGDI',
> >      '-DNO_POSIX_GOODIES',
> > @@ -1328,6 +1327,18 @@ elif host_machine.system() == 'windows'
> >      '-D__USE_MINGW_ANSI_STDIO=0',
> >    ]
> >  
> > +  msystem = get_option('msystem')
> > +  if msystem != ''
> > +    mingw_prefix = get_option('mingw_prefix')
> > +    if mingw_prefix == ''
> > +      mingw_prefix = '/' + msystem.to_lower()
> > +    endif
> > +    libgit_c_args += [
> > +      '-DENSURE_MSYSTEM_IS_SET="' + msystem + '"',
> > +      '-DMINGW_PREFIX="' + mingw_prefix + '"'
> > +    ]
> > +  endif
> 
> Lowercase mingw_prefix in Meson world corresponds to MINGW_PREFIX in
> Make world, I guess.  -DMINGW_PRFIX gets mingw_prefix which begins
> with a slash.
> 
> I do not do Windows or Meson, but doesn't this contradict with what
> we have in [12/12], part of which says:
> 
> diff --git a/config.mak.uname b/config.mak.uname
> index 2f7d445eb3..0b63be10b7 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -535,7 +535,9 @@ endif
>  		compat/win32/pthread.o compat/win32/syslog.o \
>  		compat/win32/trace2_win32_process_info.o \
>  		compat/win32/dirent.o
> -	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY -DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
> +	COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DDETECT_MSYS_TTY \
> +		-DENSURE_MSYSTEM_IS_SET="\"$(MSYSTEM)\"" -DMINGW_PREFIX="\"$(patsubst /%,%,$(MINGW_PREFIX))\"" \
> +		-DNOGDI -DHAVE_STRING_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
>  	BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -ENTRY:wmainCRTStartup -SUBSYSTEM:CONSOLE
>  	# invalidcontinue.obj allows Git's source code to close the same file
>  	# handle twice, or to access the osfhandle of an already-closed stdout
> 
> 
> IOW, -DMINGW_PREFIX passed to the compiler strips leading slash from
> $(MINGW_PREFIX).
> 
> Isn't it necessary to strip the leading slash from ming_prefix also
> on the Meson side?

Correct. Since Git for Windows does not use Meson to build the project,
and since the Visual C-based builds (including CI's `windows-meson-build`)
do not use `MSYSTEM`, this was not caught earlier. The next iteration will
have the fix.

Ciao,
Johannes

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper"
  2026-08-05 14:26 ` [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper" Johannes Schindelin via GitGitGadget
@ 2026-08-06 17:26   ` Junio C Hamano
  0 siblings, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2026-08-06 17:26 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Johannes Schindelin

"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?

> +		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)?  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.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-08-06 17:26 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 14:26 [PATCH 00/12] Upstream some more Git for Windows' patches Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 01/12] mingw: include the Python parts in the build Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 02/12] mingw: stop hard-coding `CC = gcc` Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 03/12] mingw: drop the -D_USE_32BIT_TIME_T option Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 04/12] mingw: only use -Wl,--large-address-aware for 32-bit builds Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 05/12] mingw: avoid over-specifying `--pic-executable` Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 06/12] mingw: set the prefix and HOST_CPU as per MSYS2's settings Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 07/12] mingw: only enable the MSYS2-specific stuff when compiling in MSYS2 Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 08/12] mingw: rely on MSYS2's metadata instead of hard-coding it Johannes Schindelin via GitGitGadget
2026-08-05 17:29   ` Junio C Hamano
2026-08-06 12:50     ` Johannes Schindelin
2026-08-05 14:26 ` [PATCH 09/12] windows: skip linking `git-<command>` for built-ins Johannes Schindelin via GitGitGadget
2026-08-05 17:12   ` Junio C Hamano
2026-08-05 14:26 ` [PATCH 10/12] mingw: always define `ETC_*` for MSYS2 environments Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 11/12] mingw: ensure valid CTYPE Johannes Schindelin via GitGitGadget
2026-08-05 14:26 ` [PATCH 12/12] mingw: allow `git.exe` to be used instead of the "Git wrapper" Johannes Schindelin via GitGitGadget
2026-08-06 17:26   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox