fix delayed save + exclude manual mode
[inav.git] / cmake / GetGitRevisionDescription.cmake.in
blob6d8b708efe56a66852752a7a30ec5c16b51cdc9e
2 # Internal file for GetGitRevisionDescription.cmake
4 # Requires CMake 2.6 or newer (uses the 'function' command)
6 # Original Author:
7 # 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
8 # http://academic.cleardefinition.com
9 # Iowa State University HCI Graduate Program/VRAC
11 # Copyright Iowa State University 2009-2010.
12 # Distributed under the Boost Software License, Version 1.0.
13 # (See accompanying file LICENSE_1_0.txt or copy at
14 # http://www.boost.org/LICENSE_1_0.txt)
16 set(HEAD_HASH)
18 file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
20 string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
21 if(HEAD_CONTENTS MATCHES "ref")
22         # named branch
23         string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
24         if(EXISTS "@GIT_DIR@/${HEAD_REF}")
25                 configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
26         else()
27                 configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
28                 file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
29                 if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
30                         set(HEAD_HASH "${CMAKE_MATCH_1}")
31                 endif()
32         endif()
33 else()
34         # detached HEAD
35         configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
36 endif()
38 if(NOT HEAD_HASH)
39         file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
40         string(STRIP "${HEAD_HASH}" HEAD_HASH)
41 endif()