Project

General

Profile

Bug #39039 » git_search_fix.patch

Tony Davies, 04/20/2020 02:24 AM

View differences:

cmake/modules/GetGitRevisionDescription.cmake 2020-03-24 04:47:45.000000000 +1100 → cmake/modules/GetGitRevisionDescription.cmake 2020-04-18 23:37:56.911878855 +1000
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
set(GIT_DIR "${CMAKE_SOURCE_DIR}/.git")
if(NOT EXISTS "${GIT_DIR}") # .git dir not found
# We have reached the top of the source tree, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
# check if this is a submodule or git-worktree
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} gitdirfile)
(3-3/7)