Skip to content

Commit

Permalink
Now works with git worktrees as well
Browse files Browse the repository at this point in the history
  • Loading branch information
aphecetche authored and Dario Berzano committed May 9, 2016
1 parent aeb9fc4 commit a8b913e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cmake/CheckGitVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(ALIROOT_SERIAL 0)
set(ALIROOT_GITREFTYPE "")

# Checks if the sources where cloned as a full git repository
if(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
if((EXISTS ${AliRoot_SOURCE_DIR}/.git/) OR (EXISTS ${AliRoot_SOURCE_DIR}/.git))
# Git installation mandatory
find_package(Git REQUIRED)

Expand Down Expand Up @@ -194,9 +194,9 @@ if(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
# it does not get here
message(FATAL_ERROR "Git type error")
endif()
else(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
else()
message(WARNING "AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
endif(EXISTS ${AliRoot_SOURCE_DIR}/.git/)
endif()

# Use the output of git describe for RPM versions, but strip invalid characters.
string(REGEX REPLACE "[^A-Za-z0-9_.]" "." ALIROOT_VERSION_RPM ${ALIROOT_GIT_DESCRIBE})
Expand Down
8 changes: 6 additions & 2 deletions cmake/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ function(get_git_head_revision _refspecvar _hashvar)
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
if(NOT IS_ABSOLUTE ${GIT_DIR_RELATIVE})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
else()
set(GIT_DIR "${GIT_DIR_RELATIVE}")
endif()
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
Expand Down
5 changes: 5 additions & 0 deletions cmake/GetGitRevisionDescription.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ if(HEAD_CONTENTS MATCHES "ref")
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
set(HEAD_HASH "${HEAD_REF}")
elseif(EXISTS "@GIT_DIR@/commondir")
# worktree
file(STRINGS "@GIT_DIR@/commondir" COMMON_DIR LIMIT_COUNT 1)
get_filename_component(COMMON_DIR_ABSPATH "${COMMON_DIR}" ABSOLUTE BASE_DIR ${GIT_DIR})
configure_file("${COMMON_DIR_ABSPATH}/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
endif()
else()
# detached HEAD
Expand Down

0 comments on commit a8b913e

Please sign in to comment.