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>
This commit is contained in:
Acho Arnold Ewin 2026-07-07 10:26:26 +03:00
parent edfaa000f2
commit 59817efa8e
No known key found for this signature in database
GPG key ID: B0FEBE90309CD894

View file

@ -39,16 +39,21 @@ goto :defaultpath
rem remove the last slash
SET bindir=%bindir:~0,-1%
for %%G in ("%bindir%") do set installdir=%%~dpG
if exist "%installdir%mingw64" (
set PREFIX=%installdir%mingw64
) else if exist "%installdir%clangarm64" (
set PREFIX=%installdir%clangarm64
) else if exist "%installdir%..\mingw64" (
set PREFIX=%installdir%..\mingw64
) else if exist "%installdir%..\clangarm64" (
set PREFIX=%installdir%..\clangarm64
rem strip a trailing slash so we can inspect the leaf directory name
if "%installdir:~-1%"=="\" set installdir=%installdir:~0,-1%
rem git.exe found under <GitRoot>\mingw64\bin or <GitRoot>\clangarm64\bin
rem means installdir already is the architecture directory itself
for %%G in ("%installdir%") do set archdir=%%~nxG
if /I "%archdir%"=="mingw64" (
set PREFIX=%installdir%
) else if /I "%archdir%"=="clangarm64" (
set PREFIX=%installdir%
) else if exist "%installdir%\mingw64" (
set PREFIX=%installdir%\mingw64
) else if exist "%installdir%\clangarm64" (
set PREFIX=%installdir%\clangarm64
) else (
set PREFIX=%installdir%mingw64
set PREFIX=%installdir%\mingw64
)
goto :foundprefix