Properly detecting git revision
Abel Luck
abel at guardianproject.info
Thu Nov 15 14:21:18 CET 2012
Hi,
In many of gnupg's libraries you detect the git revision number in
configure.ac using the command:
git branch -v 2>/dev/null | awk '/^\* / {printf "%s",$3}'
This works well enough when you are in a normal state, but when the repo
is a submodule the state of the repo is not in a branch, example:
(libgpg-error as submodule) $ git batch -v
* (no branch) a7eb1be Remove non-source file from the repo.
master 09544df Add the mailing list to AUTHORS.
This results in awk detecting the revision number as "branch)", which of
course isn't good, moreover, when doing Android builds m4 chokes on the
output aborting the build.
The proper way, imho, of detecting the revision number is:
git rev-parse --short HEAD 2> /dev/null | tr -d '\n'
The result is exactly the same, but relies on less sketchy parsing of
git output.
Shall I submit patches for all the affected repos?
~abel
More information about the Gnupg-devel
mailing list