autotools: support detached HEAD (BMC #20093)

A detached HEAD has a hash in .git/HEAD. This confused
gen-autotools.sh which tried to resolve it via "git show-ref", which
in turn only works for refs.

Now gen-autotools.sh checks for real hashes in .git/HEAD and truncates
them directly, without involving show-ref in this case.
This commit is contained in:
Patrick Ohly 2011-07-06 16:33:50 +02:00
parent 210b2dca66
commit 1a9489b662

View file

@ -51,7 +51,14 @@ checksource () {
fi
describe=`git describe --tags`
hash=`cat .git/HEAD | sed -e 's/ref: //'`
hash=`git show-ref --abbrev --hash --verify $hash`
if [ "`echo $hash | sed -e 's/[0-9a-fA-F]//g'`" ] ; then
# contains other characters than simple hex, probably a reference:
# convert to abbreviated hash
hash=`git show-ref --abbrev --hash --verify $hash`
else
# already a hash, abbreviate
hash=`echo $hash | sed -e 's/\(......\).*/\1/'`
fi
# detect -<number of changes>-g<hash> suffix added when tag is older than HEAD
if perl -e "exit !('$describe' =~ m/-[0-9]+-[0-9a-g]{8}\$/);"; then
# remove suffix to get tag (doesn't matter if we do not pick