summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMatt McCormick <matt.mccormick@kitware.com>2012-07-27 17:38:01 (GMT)
committerBrad King <brad.king@kitware.com>2012-11-13 18:34:43 (GMT)
commit9b66c8faf5a2c0d482c5565056ce844b7b4570ad (patch)
treee2e9fc87f9e955369b3428e1a82423d90fd027e6 /Modules
parent2619f4d87a0080cbe6e739529913bf28c0d93d12 (diff)
downloadCMake-9b66c8faf5a2c0d482c5565056ce844b7b4570ad.zip
CMake-9b66c8faf5a2c0d482c5565056ce844b7b4570ad.tar.gz
CMake-9b66c8faf5a2c0d482c5565056ce844b7b4570ad.tar.bz2
ExternalProject: Always do a git fetch for a remote ref.
Remote git refs always require a git fetch, because the remote may move around where the ref points.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/ExternalProject.cmake15
1 files changed, 14 insertions, 1 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 7a8aa5f..2355dac 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -418,6 +418,19 @@ if(error_code)
message(FATAL_ERROR \"Failed to get the hash for HEAD\")
endif()
+execute_process(
+ COMMAND \"${git_EXECUTABLE}\" show-ref ${git_tag}
+ WORKING_DIRECTORY \"${work_dir}\"
+ OUTPUT_VARIABLE show_ref_output
+ )
+# If a remote ref is asked for, which can possibly move around,
+# we must always do a fetch and checkout.
+if(\"\${show_ref_output}\" MATCHES \"remotes\")
+ set(is_remote_ref 1)
+else()
+ set(is_remote_ref 0)
+endif()
+
# This will fail if the tag does not exist (it probably has not been fetched
# yet).
execute_process(
@@ -428,7 +441,7 @@ execute_process(
)
# Is the hash checkout out that we want?
-if(error_code OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"))
+if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"))
execute_process(
COMMAND \"${git_EXECUTABLE}\" fetch
WORKING_DIRECTORY \"${work_dir}\"