summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2012-02-22 10:55:49 -0800
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:51:49 -0700
commit8d19f9538f6f732375344c55039e2d8195429d4a (patch)
treedb6fb6af030a32d2709494252c65e0fa750a57fb
parentfeaafb2b8cc047b02d25edaf3ed4d2869bf5733f (diff)
setlocalversion: Include post Linus git tags in LOCALVERSION_AUTO
The localversion detection script assumes that if there's a tag describing the commit the toplevel Makefile would indicate what that version is. This is usually true because Linus tags a commit and updates the Makefile at the same time to make a release. Unfortunately this means that any other tags made on the kernel are ignored and not used in the localversion output. For example, consider Linus tagged v3.0-rc5 and I have worked on a bunch of commits based off that tag and then tagged my branch with another tag called "changes-for-linus". Ideally I would like to see the kernel is based off v3.0-rc5 at the tag changes-for-linus. When localversion detects the version it assumes that the kernel is v3.0-rc5 because a tag is on the current commit but it doesn't confirm that the tag matches the Makefile. It then proceeds to throw away everything after the patch level and git commit hash from git describe output so we lost the tag changes-for-linus and are left with: v3.0-rc5-0003-g234ad Instead of doing that always try to describe the tree regardless of whether or not there is an exact match (unless we are doing --short output and just want to put a + after the version). Include the hash of the tag so that we get a bit more information about the tree that was built, but be sure to throw away any tags from Linus himself that start with v3.* so that we get output like: v3.0-rc5-g1561da-linus-0003-g234ad Change-Id: I9c4d03c61650658676f221680c61899305c6217a Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
-rwxr-xr-xscripts/setlocalversion23
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 63d91e22ed7c..43f29132a28c 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -48,7 +48,20 @@ scm_version()
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
# it, because this version is defined in the top level Makefile.
- if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
+ if atag="`git describe --exact-match --abbrev=0 2>/dev/null`"; then
+ # 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" != "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 --tags $atag 2>/dev/null`"
+ fi
+ else
# If only the short version is requested, don't bother
# running further git commands
@@ -57,10 +70,12 @@ scm_version()
return
fi
# If we are past a tagged commit (like
- # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
+ # "v2.6.30-rc5-302-g72357d5"), we pretty print it and
+ # include the hash of any new tag on top.
if atag="`git describe 2>/dev/null`"; then
- echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
-
+ 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 --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