setlocalversion: Fix version when built/synced on a tag
If building on a tag we check to make sure the version in the
Makefile matches the tag we're building at. That would be a
string comparison and not an integer comparison. Change the test
accordingly. Right now we'll just see 3.0.8 or 3.0.8-dirty if the
kernel is built on a tag.
Similarly if we're synced to a tag we may have two references to
the same object, 1 in the local repo and one in the remote. Force
the show-ref to only look at tags so we only ever describe on
ref instead of two.
Change-Id: I694947b434db8f95d4c0b9f6e68702c65a1ee281
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index d2690c3..3b6d5b7 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -51,14 +51,14 @@
# Make sure we're at the tag that matches the Makefile.
# If not place the hash of the tag as well for
# v2.6.30-rc5-g314aef
- if [ "x$atag" -ne "x$VERSION" ]; then
+ if [ "x$atag" != "x$VERSION" ]; then
# If only the short version is requested,
# don't bother running further git commands
if $short; then
echo "+"
return
fi
- printf '%s%s' -g "`git show-ref -s --abbrev $atag 2>/dev/null`"
+ printf '%s%s' -g "`git show-ref -s --abbrev --tags $atag 2>/dev/null`"
fi
else
@@ -74,7 +74,7 @@
if atag="`git describe 2>/dev/null`"; then
tag="`git describe --abbrev=0 2>/dev/null`"
commit="`echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'`"
- printf '%s%s%s' -g "`git show-ref -s --abbrev $tag 2>/dev/null`" $commit
+ printf '%s%s%s' -g "`git show-ref -s --abbrev --tags $tag 2>/dev/null`" $commit
# If we don't have a tag at all we print -g{commitish}.
else
printf '%s%s' -g $head