@@ -46,22 +46,15 @@ set(__get_git_revision_description YES)
4646get_filename_component (_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE } PATH )
4747
4848function (get_git_head_revision _refspecvar _hashvar )
49- set (GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR } " )
50- set (GIT_DIR "${GIT_PARENT_DIR} /.git" )
51- while (NOT EXISTS "${GIT_DIR} " ) # .git dir not found, search parent directories
52- set (GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR} " )
53- get_filename_component (GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH )
54- if (GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
55- # We have reached the root directory, we are not in git
56- set (${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE )
57- set (${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE )
58- return ()
59- endif ()
60- set (GIT_DIR "${GIT_PARENT_DIR} /.git" )
61- endwhile ()
49+ set (GIT_DIR "${CMAKE_CURRENT_SOURCE_DIR } /.git" )
50+ if (NOT EXISTS "${GIT_DIR} " )
51+ set (${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE )
52+ set (${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE )
53+ return ()
54+ endif ()
6255 # check if this is a submodule
63- if (NOT IS_DIRECTORY ${GIT_DIR} )
64- file (READ ${GIT_DIR} submodule )
56+ if (NOT IS_DIRECTORY " ${GIT_DIR} " )
57+ file (READ " ${GIT_DIR} " submodule )
6558 string (REGEX REPLACE "gitdir: (.*)\n $" "\\ 1" GIT_DIR_RELATIVE ${submodule} )
6659 get_filename_component (SUBMODULE_DIR ${GIT_DIR} PATH )
6760 get_filename_component (GIT_DIR ${SUBMODULE_DIR} /${GIT_DIR_RELATIVE} ABSOLUTE )
0 commit comments