Skip to content

Commit bc476e5

Browse files
authored
Synchronize the mingw-w64-git definition with MSYS2 (#184)
When I [upstreamed](msys2#26470) the package definition, I needed to perform a couple of adjustments. Let's pull them into Git for Windows proper, so that next time the sync can result in an identical `mingw-w64-git/` subdirectory (currently, there are changes in Git for Windows already that did not make it into MSYS2 yet, from #182 and #183, which cause a temporary divergence).
2 parents 3fde392 + eb05020 commit bc476e5

File tree

4 files changed

+41
-97
lines changed

4 files changed

+41
-97
lines changed

mingw-w64-git/PKGBUILD

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ makedepends=('git' 'openssh' 'ca-certificates' 'xmlto' 'docbook-xsl' 'docbook-xs
3434
"${MINGW_PACKAGE_PREFIX}-openssl"
3535
"${MINGW_PACKAGE_PREFIX}-pcre2"
3636
"${MINGW_PACKAGE_PREFIX}-asciidoctor")
37-
install=git.install
3837

3938
source=("${_realname}"::"git+https://github.com/git-for-windows/git.git#tag=v$tag"
4039
'git-for-windows.ico'
@@ -62,15 +61,15 @@ sha256sums=('5f624e2511c445b832d9bbd65a74c27630be79994bf38dde4a4f8013d89e60e0'
6261
'a9dcba5aebc93ae7aacdee03275780fc6c0f15e88fda30c93041e75851e75090'
6362
'7e6c5f3dc6a4209dca0e1f38880b2978500a5c745c04bc60dbeda5fc48e8d3cb'
6463
'80b0b11efe5a2f9b4cd92f28c260d0b3aad8b809c34ed95237c59b73e08ade0b'
65-
'20613488bbd66bced2ef786448dc335c9cc7a5ef8be800e0d5bab83e36faf584'
64+
'26b54e0d45fc172424d941fe7b8b87ec8b5b81f15a71954ca212f4fc9887c8fb'
6665
'dab3e41e935a33f443a4ff4ef4ce92c191b6d952d9eb37e14885540ad5af99ed'
6766
'c975292adae1f2666f07f8ee9b7d50576da249d9151c6bd211602adc8d37b6ab'
6867
'53e630f581bee400100d074189754413afb6670ba1c09a5a3a09c5b575e41e60'
6968
'db754d6fe6722ad54d43df15ee93b1d9cead406158ed84dcbf35e5b4225469ed'
7069
'db754d6fe6722ad54d43df15ee93b1d9cead406158ed84dcbf35e5b4225469ed'
7170
'cbed8b133eb9eec9972f146be5c3ff49db29b2fff8ab9c87a6d0c646c08a5128'
7271
'027155aa6ca5f11ad7bcb89550a470935a9f22a9d5b3ab80a9eb209983258c1f'
73-
'386e965e184f657a5373b117c59e9e8711713e09177623a77718358cbc46296e'
72+
'b79173d806af70f211ce7b67684d8f82f5a2661e186eabf831935cf0f360c86d'
7473
'7413506c59d25621e475aa45447993748332c72cfbb4cf94cce6bee6f1218a09'
7574
'6d83e1cb1acdb6eb1f2d5cb9299298e57680f5ca43d43c3e67c9da17f21b9b01')
7675

@@ -505,6 +504,38 @@ package_git-p4 () {
505504
install -m644 Documentation/git-p4.html "$pkgdir/$MINGW_PREFIX/share/doc/git-doc/"
506505
}
507506

507+
echo 'bin_path () {
508+
echo "$(cygpath -am / | sed "s/^\\([A-Z]\\):/\\/proc\\/cygdrive\\/\\1/")/bin"
509+
}
510+
511+
copy_files () {
512+
mkdir -p "$2" &&
513+
cp "$1"/share/git/compat-bash.exe "$2"/bash.exe &&
514+
cp "$1"/share/git/compat-bash.exe "$2"/sh.exe &&
515+
cp /cmd/git.exe "$2"/
516+
}
517+
518+
post_install () {
519+
# Install git, bash and sh redirectors into the bin/ directory
520+
# This needs to use the absolute path because /bin/ is overlayed by
521+
# /usr/bin/.
522+
copy_files '"$MINGW_PREFIX"' "$(bin_path)"
523+
}
524+
525+
post_upgrade () {
526+
post_install
527+
}
528+
529+
remove_files () {
530+
rm "$1"/git.exe "$1"/bash.exe "$1"/sh.exe &&
531+
{ test -n "$(ls -A "$1")" || rm -r "$1"; }
532+
}
533+
534+
post_remove () {
535+
remove_files "$(bin_path)"
536+
}
537+
' >"${MINGW_PACKAGE_PREFIX}-git-for-windows-addons.install"
538+
508539
package_git-for-windows-addons () {
509540
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}=${pkgver}"
510541
"${MINGW_PACKAGE_PREFIX}-${_realname}-subtree"
@@ -514,6 +545,7 @@ package_git-for-windows-addons () {
514545
"${MINGW_PACKAGE_PREFIX}-gitk"
515546
"${MINGW_PACKAGE_PREFIX}-${_realname}-gui")
516547
pkgdesc="Git for Windows extra executables and wrappers (mingw-w64)"
548+
install=${MINGW_PACKAGE_PREFIX}-git-for-windows-addons.install
517549

518550
cd "$srcdir"/git
519551

mingw-w64-git/git-wrapper.c

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -114,48 +114,6 @@ static void my_path_append(LPWSTR list, LPCWSTR path, size_t alloc)
114114
}
115115
}
116116

117-
static int running_on_arm64 = -1;
118-
119-
static int is_running_on_arm64_hardware()
120-
{
121-
if (running_on_arm64 >= 0)
122-
return running_on_arm64;
123-
124-
USHORT process_machine = 0;
125-
USHORT native_machine = 0;
126-
127-
/* Note: IsWow64Process2 is only available in Windows 10 1511+ */
128-
BOOL (WINAPI* IsWow64Process2)(HANDLE, PUSHORT, PUSHORT) =
129-
(BOOL (WINAPI *)(HANDLE, PUSHORT, PUSHORT))
130-
GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process2");
131-
132-
running_on_arm64 = IsWow64Process2 &&
133-
IsWow64Process2(GetCurrentProcess(), &process_machine, &native_machine) &&
134-
native_machine == 0xaa64;
135-
136-
return running_on_arm64;
137-
}
138-
139-
static int is_running_on_arm64_msystem(LPWSTR top_level_path, LPWSTR msystem_bin)
140-
{
141-
int ret=0;
142-
size_t len = wcslen(top_level_path);
143-
144-
/* Does /clangarm64/bin exist? */
145-
my_path_append(top_level_path, L"clangarm64/bin", MAX_PATH);
146-
if (_waccess(top_level_path, 0) != -1) {
147-
wcscpy(msystem_bin, L"clangarm64/bin");
148-
ret=1;
149-
}
150-
top_level_path[len] = L'\0';
151-
return ret;
152-
}
153-
154-
static inline int is_running_on_arm64(LPWSTR top_level_path, LPWSTR msystem_bin)
155-
{
156-
return is_running_on_arm64_hardware() && is_running_on_arm64_msystem(top_level_path, msystem_bin);
157-
}
158-
159117
static int is_system32_path(LPWSTR path)
160118
{
161119
WCHAR system32[MAX_PATH];
@@ -165,20 +123,11 @@ static int is_system32_path(LPWSTR path)
165123

166124
static void setup_environment(LPWSTR top_level_path, int full_path)
167125
{
168-
WCHAR msystem[64];
169126
LPWSTR path2 = NULL;
170127
int len;
171128

172129
/* Set MSYSTEM */
173-
if (running_on_arm64 > 0) {
174-
swprintf(msystem, sizeof(msystem),
175-
L"CLANGARM64");
176-
} else {
177-
swprintf(msystem, sizeof(msystem),
178-
L"MINGW%d", (int)sizeof(void*) * 8);
179-
}
180-
181-
SetEnvironmentVariable(L"MSYSTEM", msystem);
130+
SetEnvironmentVariable(L"MSYSTEM", MSYSTEM);
182131

183132
/* if not set, set PLINK_PROTOCOL to ssh */
184133
if (!GetEnvironmentVariable(L"PLINK_PROTOCOL", NULL, 0))
@@ -633,8 +582,6 @@ static void initialize_top_level_path(LPWSTR top_level_path, LPWSTR exepath,
633582
while (strip_count) {
634583
if (strip_count < 0) {
635584
int len = wcslen(top_level_path);
636-
if (is_running_on_arm64(top_level_path, msystem_bin))
637-
return;
638585
my_path_append(top_level_path, msystem_bin, MAX_PATH);
639586
if (_waccess(top_level_path, 0) != -1) {
640587
/* We are in an MSys2-based setup */
@@ -665,8 +612,6 @@ static void initialize_top_level_path(LPWSTR top_level_path, LPWSTR exepath,
665612
if (strip_count > 0)
666613
--strip_count;
667614
}
668-
/* Only enable ARM64 support if <top-level>/arm64/bin/ exists */
669-
is_running_on_arm64(top_level_path, msystem_bin);
670615
}
671616

672617
static void maybe_read_config(LPWSTR top_level_path)
@@ -720,9 +665,10 @@ int main(void)
720665
LPWSTR working_directory = NULL;
721666
LPCWSTR prefix_args = NULL;
722667

723-
/* Determine MSys2-based Git path. */
724-
swprintf(msystem_bin, sizeof(msystem_bin),
725-
L"mingw%d\\bin", (int) sizeof(void *) * 8);
668+
/* Determine MSYS2-based `bin` path. */
669+
wcscpy(msystem_bin, MSYSTEM L"\\bin");
670+
for (wchar_t *p = msystem_bin; *p; p++)
671+
*p = towlower(*p);
726672
*top_level_path = L'\0';
727673

728674
/* get the installation location */

mingw-w64-git/git.install

Lines changed: 0 additions & 35 deletions
This file was deleted.

mingw-w64-git/mingw-w64-git.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ git-wrapper$(X): git-wrapper.o git.res
66

77
git-wrapper.o: %.o: ../%.c GIT-PREFIX
88
$(QUIET_CC)$(CC) $(ALL_CFLAGS) $(COMPAT_CFLAGS) \
9+
-DMSYSTEM=L"\"$(MSYSTEM)\"" \
910
-fno-stack-protector -o $*.o -c -Wall -Wwrite-strings $<
1011

1112
git-bash.res git-cmd.res git-wrapper.res gitk.res compat-bash.res tig.res: \

0 commit comments

Comments
 (0)