summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject-gitupdate.cmake.in
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2021-05-09 02:33:16 (GMT)
committerCraig Scott <craig.scott@crascit.com>2021-05-09 02:33:16 (GMT)
commit5e941a545bf5882ddf101cad383dc815fb651f26 (patch)
treeae3f6b468a3cfb2c8fec86eba4c6455b104521aa /Modules/ExternalProject-gitupdate.cmake.in
parentfdbb5a599fc373a1ec7dbbfdcca34ff9669f3c48 (diff)
downloadCMake-5e941a545bf5882ddf101cad383dc815fb651f26.zip
CMake-5e941a545bf5882ddf101cad383dc815fb651f26.tar.gz
CMake-5e941a545bf5882ddf101cad383dc815fb651f26.tar.bz2
ExternalProject: Ensure git fetch if updating to hash we don't have yet
In ac6a4d4884 (ExternalProject: Improve robustness of update step, 2020-10-17), the method used to check whether we already have a commit or not was changed from using git rev-list to git rev-parse. The new logic assumed rev-parse would output nothing if given a commit hash it didn't know about, but it simply prints the hash again without raising an error in this scenario. Amend that logic by adding ^{commit} to the ref to ensure we do get an error if that ref is not currently known. Fixes: #22166
Diffstat (limited to 'Modules/ExternalProject-gitupdate.cmake.in')
-rw-r--r--Modules/ExternalProject-gitupdate.cmake.in2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/ExternalProject-gitupdate.cmake.in b/Modules/ExternalProject-gitupdate.cmake.in
index 7033918..461e323 100644
--- a/Modules/ExternalProject-gitupdate.cmake.in
+++ b/Modules/ExternalProject-gitupdate.cmake.in
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5)
function(get_hash_for_ref ref out_var err_var)
execute_process(
- COMMAND "@git_EXECUTABLE@" rev-parse "${ref}"
+ COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^{commit}"
WORKING_DIRECTORY "@work_dir@"
RESULT_VARIABLE error_code
OUTPUT_VARIABLE ref_hash