File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,24 @@ macro(run_vcpkg)
3939 if (EXISTS "${_vcpkg_args_VCPKG_DIR} " AND EXISTS "${_vcpkg_args_VCPKG_DIR} /vcpkg${CMAKE_EXECUTABLE_SUFFIX} " )
4040 message (STATUS "vcpkg is already installed at ${_vcpkg_args_VCPKG_DIR} ." )
4141 if (${_vcpkg_args_ENABLE_VCPKG_UPDATE} )
42+
43+ if (NOT
44+ "${_vcpkg_args_VCPKG_REV} "
45+ STREQUAL
46+ "" )
47+ # detect if the head is detached, if so, switch back before calling git pull on a detached head
48+ set (GIT_STATUS "" )
49+ execute_process (
50+ COMMAND "git" "rev-parse" "--abbrev-ref" "--symbolic-full-name" "HEAD"
51+ OUTPUT_VARIABLE GIT_STATUS
52+ WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR} "
53+ OUTPUT_STRIP_TRAILING_WHITESPACE)
54+ if ("${GIT_STATUS} " STREQUAL "HEAD" )
55+ message (STATUS "Switching back before updating" )
56+ execute_process (COMMAND "git" "switch" "-" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR} " )
57+ endif ()
58+ endif ()
59+
4260 message (STATUS "Updating the repository..." )
4361 execute_process (COMMAND "git" "pull" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR} " )
4462 endif ()
You can’t perform that action at this time.
0 commit comments