From f5ded4fced278477cbde3f5ef0b683eb7d35f838 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Wed, 22 Feb 2012 10:55:49 -0800 Subject: [PATCH] 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). Always include 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-changes-for-linus-0003-g234ad Change-Id: I9c4d03c61650658676f221680c61899305c6217a Signed-off-by: Stephen Boyd --- scripts/setlocalversion | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 4d403844e13..2c528664fb8 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -55,16 +55,17 @@ scm_version() echo "+" return fi - # If we are past a tagged commit (like - # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="`git describe 2>/dev/null`"; then - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' - - # If we don't have a tag at all we print -g{commitish}. - else - printf '%s%s' -g $head - fi fi + # If we are past a tagged commit (like + # "v2.6.30-rc5-302-g72357d5"), we pretty print it but strip + # off the v2.6.30-rc5 part because that's in the Makefile. + if atag="`git describe 2>/dev/null`"; then + atag="-${atag/v$KERNELVERSION-/}" + # If we don't have a tag at all we print -g{commitish}. + else + atag="-g$head" + fi + printf '%s' "$atag" # Is this git on svn? if git config --get svn-remote.svn.url >/dev/null; then