From 0ed10e5e890316920b746c8d3a3f4b9a292c4b0b Mon Sep 17 00:00:00 2001 From: Florian Schwalm Date: Wed, 29 Jul 2020 22:39:46 +0200 Subject: [PATCH] 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. --- vendor/lib/lib_git.cmd | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index a78badf..f61c4b2 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -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=