Skip to content

Commit 7f36d37

Browse files
AchoArnoldCopilotCopilot
authored
fix: support Windows ARM64 (clangarm64) in install.cmd (#1259)
* fix: support Windows ARM64 (clangarm64) in install.cmd Git for Windows on ARM64 uses a `clangarm64` directory instead of `mingw64`. The installer now auto-detects `clangarm64` when `mingw64` is not present, so it works out of the box on ARM64 Windows machines without requiring the user to manually supply the path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: remove trailing whitespace from install.cmd Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: correctly resolve PREFIX when git.exe is under the arch dir in PATH When 'where git.exe' resolves to ...\mingw64\bin\git.exe or ...\clangarm64\bin\git.exe, installdir becomes the architecture directory itself. Detect that case by inspecting the leaf directory name instead of appending mingw64/clangarm64 (which produced non-existent ...\mingw64\mingw64 paths) or using ..\ segments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 184d37e commit 7f36d37

1 file changed

Lines changed: 36 additions & 11 deletions

File tree

install.cmd

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,34 @@ goto :defaultpath
3939
rem remove the last slash
4040
SET bindir=%bindir:~0,-1%
4141
for %%G in ("%bindir%") do set installdir=%%~dpG
42-
set PREFIX=%installdir%mingw64
42+
rem strip a trailing slash so we can inspect the leaf directory name
43+
if "%installdir:~-1%"=="\" set installdir=%installdir:~0,-1%
44+
rem git.exe found under <GitRoot>\mingw64\bin or <GitRoot>\clangarm64\bin
45+
rem means installdir already is the architecture directory itself
46+
for %%G in ("%installdir%") do set archdir=%%~nxG
47+
if /I "%archdir%"=="mingw64" (
48+
set PREFIX=%installdir%
49+
) else if /I "%archdir%"=="clangarm64" (
50+
set PREFIX=%installdir%
51+
) else if exist "%installdir%\mingw64" (
52+
set PREFIX=%installdir%\mingw64
53+
) else if exist "%installdir%\clangarm64" (
54+
set PREFIX=%installdir%\clangarm64
55+
) else (
56+
set PREFIX=%installdir%\mingw64
57+
)
4358
goto :foundprefix
4459

4560
:defaultpath
4661
:: default for Git for Windows 2.x
4762
if exist "%ProgramFiles%\Git" (
48-
set PREFIX=%ProgramFiles%\Git\mingw64
63+
if exist "%ProgramFiles%\Git\mingw64" (
64+
set PREFIX=%ProgramFiles%\Git\mingw64
65+
) else if exist "%ProgramFiles%\Git\clangarm64" (
66+
set PREFIX=%ProgramFiles%\Git\clangarm64
67+
) else (
68+
set PREFIX=%ProgramFiles%\Git\mingw64
69+
)
4970
)
5071

5172
:foundprefix
@@ -55,9 +76,11 @@ IF NOT "%~1"=="" (
5576
REM just supplying the git dir is enough...
5677
if exist "%~1\mingw64" (
5778
set PREFIX=%~1\mingw64
79+
) else if exist "%~1\clangarm64" (
80+
set PREFIX=%~1\clangarm64
5881
) else (
5982
echo Using git install path "%~1" as PREFIX, please make sure it's really a
60-
echo path to the mingw64 directory...
83+
echo path to the mingw64 or clangarm64 directory...
6184
echo.
6285
SET PREFIX=%~1
6386
)
@@ -72,12 +95,14 @@ set GIT_INSTALL_DIR=!GIT_INSTALL_DIR:"=!
7295
IF %GIT_INSTALL_DIR:~-1%==\ SET GIT_INSTALL_DIR=%GIT_INSTALL_DIR:~0,-1%
7396

7497
if not exist "%GIT_INSTALL_DIR%\mingw64" (
75-
echo No mingw64 folder found in %GIT_INSTALL_DIR%.
76-
echo.
77-
echo Please supply a proper "Git for Windows 2.x" install path:
78-
echo "install.cmd c:\[git-install-path]"
79-
set ERROR=1
80-
goto :exit
98+
if not exist "%GIT_INSTALL_DIR%\clangarm64" (
99+
echo No mingw64 or clangarm64 folder found in %GIT_INSTALL_DIR%.
100+
echo.
101+
echo Please supply a proper "Git for Windows 2.x" install path:
102+
echo "install.cmd c:\[git-install-path]"
103+
set ERROR=1
104+
goto :exit
105+
)
81106
)
82107

83108
echo Installing to %PREFIX%
@@ -116,7 +141,7 @@ FOR /R "%GITEXTRAS%\bin" %%i in (*.*) DO (
116141
TYPE "%GITEXTRAS%\helper\reset-env" >> "%PREFIX%\bin\%%~ni"
117142
TYPE "%GITEXTRAS%\helper\git-extra-utility" >> "%PREFIX%\bin\%%~ni"
118143
TYPE "%GITEXTRAS%\helper\is-git-repo" >> "%PREFIX%\bin\%%~ni"
119-
144+
120145
REM Added /E option for installation fix on Windows 10.0.17134 and higher
121146
MORE /E +2 "%GITEXTRAS%\bin\%%~ni" >> "%PREFIX%\bin\%%~ni"
122147
)
@@ -127,7 +152,7 @@ FOR %%i in (%COMMANDS_WITHOUT_REPO%) DO (
127152
ECHO #^^!/usr/bin/env bash > "%PREFIX%\bin\%%i"
128153
TYPE "%GITEXTRAS%\helper\reset-env" >> "%PREFIX%\bin\%%i"
129154
TYPE "%GITEXTRAS%\helper\git-extra-utility" >> "%PREFIX%\bin\%%i"
130-
155+
131156
REM Added /E option for installation fix on Windows 10.0.17134 and higher
132157
MORE /E +2 "%GITEXTRAS%\bin\%%i" >> "%PREFIX%\bin\%%i"
133158
)

0 commit comments

Comments
 (0)