From a24e14992b80df1e1a676dd7d213b9e9992b5d55 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 16 Mar 2014 22:00:49 +0100 Subject: [PATCH] Don't look recursively for a .git dir The original GetGitRevisionDescription.cmake script would look for a .git dir recursively in the parent directories of its invocation; while a nice feature, it may pick up an unrelated repository if there's none in the Quassel directory. Because we know exactly where to find our own .git if it's there at all, we can remove the recursion and prevent this issue. --- cmake/modules/GetGitRevisionDescription.cmake | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/cmake/modules/GetGitRevisionDescription.cmake b/cmake/modules/GetGitRevisionDescription.cmake index aa2ef71a..10e37074 100644 --- a/cmake/modules/GetGitRevisionDescription.cmake +++ b/cmake/modules/GetGitRevisionDescription.cmake @@ -40,19 +40,12 @@ set(__get_git_revision_description YES) 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 + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() # check if this is a submodule if(NOT IS_DIRECTORY ${GIT_DIR}) file(READ ${GIT_DIR} submodule) -- 2.20.1