Commit cf86580f authored by Sutou Kouhei's avatar Sutou Kouhei Committed by Sergei Golubchik

MDEV-28032 "git submodule update --depth 1" may fail with old Git

submodules.cmake: don't use "--depth 1" with old Git

Old Git may not work with "--depth 1" when the referenced commit hash
is far from HEAD.

Newer Git improves the situation. For example:
https://github.com/git/git/commit/fb43e31f2b43076e7a30c9cd00d0241cb8cf97eb

It's safe to not use "--depth 1" with old Git.

Closes #2049
parent ecb6f9c8
...@@ -17,21 +17,30 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") ...@@ -17,21 +17,30 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
${GIT_EXECUTABLE} config cmake.update-submodules yes") ${GIT_EXECUTABLE} config cmake.update-submodules yes")
ELSEIF(git_config_get_result EQUAL 128) ELSEIF(git_config_get_result EQUAL 128)
SET(update_result 0) SET(update_result 0)
ELSEIF (cmake_update_submodules MATCHES force) ELSE()
SET(UPDATE_SUBMODULES_COMMAND
"${GIT_EXECUTABLE}" submodule update --init --recursive)
# Old Git may not work with "--depth 1".
# See also: https://github.com/git/git/commit/fb43e31f2b43076e7a30c9cd00d0241cb8cf97eb
IF(NOT GIT_VERSION_STRING VERSION_LESS "2.8.0")
SET(UPDATE_SUBMODULES_COMMAND ${UPDATE_SUBMODULES_COMMAND} --depth 1)
ENDIF()
IF(cmake_update_submodules MATCHES force)
MESSAGE(STATUS "Updating submodules (forced)") MESSAGE(STATUS "Updating submodules (forced)")
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --force --depth=1 EXECUTE_PROCESS(COMMAND ${UPDATE_SUBMODULES_COMMAND} --force
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE update_result) RESULT_VARIABLE update_result)
ELSEIF (cmake_update_submodules MATCHES yes) ELSEIF(cmake_update_submodules MATCHES yes)
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --depth=1 EXECUTE_PROCESS(COMMAND ${UPDATE_SUBMODULES_COMMAND}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE update_result) RESULT_VARIABLE update_result)
ELSE() ELSE()
MESSAGE(STATUS "Updating submodules") MESSAGE(STATUS "Updating submodules")
EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --depth=1 EXECUTE_PROCESS(COMMAND ${UPDATE_SUBMODULES_COMMAND}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE update_result) RESULT_VARIABLE update_result)
ENDIF() ENDIF()
ENDIF()
ENDIF() ENDIF()
IF(update_result OR NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt) IF(update_result OR NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment