diff options
Diffstat (limited to 'scripts/setlocalversion')
-rwxr-xr-x | scripts/setlocalversion | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 0c8741b795d0..f3d95e38a330 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,7 +70,8 @@ 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. # # Ensure the abbreviated sha1 has exactly 12 # hex characters, to make the output @@ -68,7 +82,9 @@ scm_version() # awk substr() then picks the 'g' and first 12 # hex chars. if atag="$(git describe --abbrev=12 2>/dev/null)"; then - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}' + tag="`git describe --abbrev=0 2>/dev/null`" + commit="`echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}'`" + 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}, # again using exactly 12 hex chars. |