Reorder if-else-clauses in :compare_git_versions so last else block can be reached

It is hard to spot without the brackets, but the last else block - that resets %test_dir% and
logs in verbose mode that an older user git version will be ignored - can't actually be reached.
The else block is considered to belong to the if clause "if exist "%test_dir:~0,-4%\cmd\git.exe""
that will only ever be executed if ERRORLEVEL is greather than or equal to 0, thus if the test fails,
the following else if clause "else if ERRORLEVEL 0" will always succeed and the last else block will be ignored.
Using the vendored git version may still have worked because %GIT_INSTALL_ROOT% isn't set either way,
but to enable the log message I reordered if-else-clauses and brackets in the way I think the
original author intended them to work.
This commit is contained in:
Florian Schwalm 2020-07-29 22:39:46 +02:00
parent cd50db3a7f
commit 0ed10e5e89

View File

@ -236,12 +236,14 @@ exit /b
%lib_git% compare_versions USER VENDORED
:: use the user provided git if its version is greater than, or equal to the vendored git
if ERRORLEVEL 0 if exist "%test_dir:~0,-4%\cmd\git.exe" (
set "GIT_INSTALL_ROOT=%test_dir:~0,-4%"
set test_dir=
) else if ERRORLEVEL 0 (
set "GIT_INSTALL_ROOT=%test_dir%"
set test_dir=
if ERRORLEVEL 0 (
if exist "%test_dir:~0,-4%\cmd\git.exe" (
set "GIT_INSTALL_ROOT=%test_dir:~0,-4%"
set test_dir=
) else (
set "GIT_INSTALL_ROOT=%test_dir%"
set test_dir=
)
) else (
call :verbose_output Found old %GIT_VERSION_USER% in "%test_dir%", but not using...
set test_dir=