Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions mingw-w64-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ makedepends=('git' 'openssh' 'ca-certificates' 'xmlto' 'docbook-xsl' 'docbook-xs
"${MINGW_PACKAGE_PREFIX}-openssl"
"${MINGW_PACKAGE_PREFIX}-pcre2"
"${MINGW_PACKAGE_PREFIX}-asciidoctor")
install=git.install

source=("${_realname}"::"git+https://github.com/git-for-windows/git.git#tag=v$tag"
'git-for-windows.ico'
Expand Down Expand Up @@ -62,15 +61,15 @@ sha256sums=('5f624e2511c445b832d9bbd65a74c27630be79994bf38dde4a4f8013d89e60e0'
'a9dcba5aebc93ae7aacdee03275780fc6c0f15e88fda30c93041e75851e75090'
'7e6c5f3dc6a4209dca0e1f38880b2978500a5c745c04bc60dbeda5fc48e8d3cb'
'80b0b11efe5a2f9b4cd92f28c260d0b3aad8b809c34ed95237c59b73e08ade0b'
'20613488bbd66bced2ef786448dc335c9cc7a5ef8be800e0d5bab83e36faf584'
'26b54e0d45fc172424d941fe7b8b87ec8b5b81f15a71954ca212f4fc9887c8fb'
'dab3e41e935a33f443a4ff4ef4ce92c191b6d952d9eb37e14885540ad5af99ed'
'c975292adae1f2666f07f8ee9b7d50576da249d9151c6bd211602adc8d37b6ab'
'53e630f581bee400100d074189754413afb6670ba1c09a5a3a09c5b575e41e60'
'db754d6fe6722ad54d43df15ee93b1d9cead406158ed84dcbf35e5b4225469ed'
'db754d6fe6722ad54d43df15ee93b1d9cead406158ed84dcbf35e5b4225469ed'
'cbed8b133eb9eec9972f146be5c3ff49db29b2fff8ab9c87a6d0c646c08a5128'
'027155aa6ca5f11ad7bcb89550a470935a9f22a9d5b3ab80a9eb209983258c1f'
'386e965e184f657a5373b117c59e9e8711713e09177623a77718358cbc46296e'
'b79173d806af70f211ce7b67684d8f82f5a2661e186eabf831935cf0f360c86d'
'7413506c59d25621e475aa45447993748332c72cfbb4cf94cce6bee6f1218a09'
'6d83e1cb1acdb6eb1f2d5cb9299298e57680f5ca43d43c3e67c9da17f21b9b01')

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

echo 'bin_path () {
echo "$(cygpath -am / | sed "s/^\\([A-Z]\\):/\\/proc\\/cygdrive\\/\\1/")/bin"
}

copy_files () {
mkdir -p "$2" &&
cp "$1"/share/git/compat-bash.exe "$2"/bash.exe &&
cp "$1"/share/git/compat-bash.exe "$2"/sh.exe &&
cp /cmd/git.exe "$2"/
}

post_install () {
# Install git, bash and sh redirectors into the bin/ directory
# This needs to use the absolute path because /bin/ is overlayed by
# /usr/bin/.
copy_files '"$MINGW_PREFIX"' "$(bin_path)"
}

post_upgrade () {
post_install
}

remove_files () {
rm "$1"/git.exe "$1"/bash.exe "$1"/sh.exe &&
{ test -n "$(ls -A "$1")" || rm -r "$1"; }
}

post_remove () {
remove_files "$(bin_path)"
}
' >"${MINGW_PACKAGE_PREFIX}-git-for-windows-addons.install"

package_git-for-windows-addons () {
depends=("${MINGW_PACKAGE_PREFIX}-${_realname}=${pkgver}"
"${MINGW_PACKAGE_PREFIX}-${_realname}-subtree"
Expand All @@ -514,6 +545,7 @@ package_git-for-windows-addons () {
"${MINGW_PACKAGE_PREFIX}-gitk"
"${MINGW_PACKAGE_PREFIX}-${_realname}-gui")
pkgdesc="Git for Windows extra executables and wrappers (mingw-w64)"
install=${MINGW_PACKAGE_PREFIX}-git-for-windows-addons.install

cd "$srcdir"/git

Expand Down
64 changes: 5 additions & 59 deletions mingw-w64-git/git-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,48 +114,6 @@ static void my_path_append(LPWSTR list, LPCWSTR path, size_t alloc)
}
}

static int running_on_arm64 = -1;

static int is_running_on_arm64_hardware()
{
if (running_on_arm64 >= 0)
return running_on_arm64;

USHORT process_machine = 0;
USHORT native_machine = 0;

/* Note: IsWow64Process2 is only available in Windows 10 1511+ */
BOOL (WINAPI* IsWow64Process2)(HANDLE, PUSHORT, PUSHORT) =
(BOOL (WINAPI *)(HANDLE, PUSHORT, PUSHORT))
GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process2");

running_on_arm64 = IsWow64Process2 &&
IsWow64Process2(GetCurrentProcess(), &process_machine, &native_machine) &&
native_machine == 0xaa64;

return running_on_arm64;
}

static int is_running_on_arm64_msystem(LPWSTR top_level_path, LPWSTR msystem_bin)
{
int ret=0;
size_t len = wcslen(top_level_path);

/* Does /clangarm64/bin exist? */
my_path_append(top_level_path, L"clangarm64/bin", MAX_PATH);
if (_waccess(top_level_path, 0) != -1) {
wcscpy(msystem_bin, L"clangarm64/bin");
ret=1;
}
top_level_path[len] = L'\0';
return ret;
}

static inline int is_running_on_arm64(LPWSTR top_level_path, LPWSTR msystem_bin)
{
return is_running_on_arm64_hardware() && is_running_on_arm64_msystem(top_level_path, msystem_bin);
}

static int is_system32_path(LPWSTR path)
{
WCHAR system32[MAX_PATH];
Expand All @@ -165,20 +123,11 @@ static int is_system32_path(LPWSTR path)

static void setup_environment(LPWSTR top_level_path, int full_path)
{
WCHAR msystem[64];
LPWSTR path2 = NULL;
int len;

/* Set MSYSTEM */
if (running_on_arm64 > 0) {
swprintf(msystem, sizeof(msystem),
L"CLANGARM64");
} else {
swprintf(msystem, sizeof(msystem),
L"MINGW%d", (int)sizeof(void*) * 8);
}

SetEnvironmentVariable(L"MSYSTEM", msystem);
SetEnvironmentVariable(L"MSYSTEM", MSYSTEM);

/* if not set, set PLINK_PROTOCOL to ssh */
if (!GetEnvironmentVariable(L"PLINK_PROTOCOL", NULL, 0))
Expand Down Expand Up @@ -633,8 +582,6 @@ static void initialize_top_level_path(LPWSTR top_level_path, LPWSTR exepath,
while (strip_count) {
if (strip_count < 0) {
int len = wcslen(top_level_path);
if (is_running_on_arm64(top_level_path, msystem_bin))
return;
my_path_append(top_level_path, msystem_bin, MAX_PATH);
if (_waccess(top_level_path, 0) != -1) {
/* We are in an MSys2-based setup */
Expand Down Expand Up @@ -665,8 +612,6 @@ static void initialize_top_level_path(LPWSTR top_level_path, LPWSTR exepath,
if (strip_count > 0)
--strip_count;
}
/* Only enable ARM64 support if <top-level>/arm64/bin/ exists */
is_running_on_arm64(top_level_path, msystem_bin);
}

static void maybe_read_config(LPWSTR top_level_path)
Expand Down Expand Up @@ -720,9 +665,10 @@ int main(void)
LPWSTR working_directory = NULL;
LPCWSTR prefix_args = NULL;

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

/* get the installation location */
Expand Down
35 changes: 0 additions & 35 deletions mingw-w64-git/git.install

This file was deleted.

1 change: 1 addition & 0 deletions mingw-w64-git/mingw-w64-git.mak
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ git-wrapper$(X): git-wrapper.o git.res

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

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