Merged
Conversation
%errorlevel% was always 0, even if the vendored git version was more current than the installed one Usually exiting a batch script with "exit /b exitCode" as used in :compare_versions sets %errorlevel% to the specified exit code However, this may not work if %errorlevel% was set before with "Set errorlevel=" I didn't find the location where this might have happened, but I saw the consequence of %errorlevel% always being 0 Thus I decided to use ERRORLEVEL instead as this will always work regardless of environment variable For more information check https://ss64.com/nt/errorlevel.html
…an 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.
The default setting for path enhancing is appending, so the provided unix tools don't overwrite windows tools we may want to keep. For Git this is undesired behavior, though, as we just compared git versions to decide which one we want to use. The git directory thus needs to be prepended to the path to make sure a call to git uses the version we selected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The most recent version of cmder didn't use the vendored git even if it's more current than an installed version.
This PR fixes several issues that prevented the git version comparison from correctly providing the most current git version.