1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

ExternalProject: Use ${ref}^0 to avoid MSYS/Cygwin shell substitutions

In 5e941a545b (ExternalProject: Ensure git fetch if updating to hash we
don't have yet, 2021-05-09), the form ${ref}^{commit} was used to ensure
the ref was treated as a commit. When running under a MSYS2 or
Cygwin shell, the {commit} part can be translated by the shell, leaving it as
${ref}^commit, which git doesn't understand. Use the equivalent but
safer form ${ref}^0, since it won't be subject to the shell substitution
issue.

Fixes: #22299
This commit is contained in:
Craig Scott
2021-06-20 15:40:45 +10:00
parent acd82e4690
commit 360ff17dc6

View File

@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5)
function(get_hash_for_ref ref out_var err_var) function(get_hash_for_ref ref out_var err_var)
execute_process( execute_process(
COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^{commit}" COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^0"
WORKING_DIRECTORY "@work_dir@" WORKING_DIRECTORY "@work_dir@"
RESULT_VARIABLE error_code RESULT_VARIABLE error_code
OUTPUT_VARIABLE ref_hash OUTPUT_VARIABLE ref_hash