[PATCH] Fix scripts/setlocalversion with git

From: Nico Schottelius
Date: Mon Mar 30 2009 - 08:21:51 EST


Hello!

When using trees like wireless-testing, which have untagged tags,
scripts/setlocalversion does not display any git indication for
localversion.

This patch fixes it: If git is available, but no usable tag is found,
it uses -g${head}. It skips the detection of unanottated tags via
git name-rev.

Please apply, otherwise testers like me always have '2.6.29' for trees
with unanottated tags, instead of 2.6.29-20318-g9aa4755, which helps
a lot if you've tons of kernels installed from different trees.

Sincerly,

Nico

ps: please cc on reply
--- old/scripts/setlocalversion 2009-03-27 09:37:07.160938681 +0100
+++ new/scripts/setlocalversion 2009-03-30 14:14:21.187397016 +0200
@@ -10,13 +10,12 @@

# Check for git and a git repo.
if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
- # Do we have an untagged version?
- if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
- if tag=`git describe 2>/dev/null`; then
- echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
- else
- printf '%s%s' -g $head
- fi
+ # Do we have an annotated tag?
+ if atag=`git describe 2>/dev/null`; then
+ echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
+ # add -g${head}, if there is no usable tag
+ else
+ printf '%s%s' -g $head
fi

# Is this git on svn?

Attachment: signature.asc
Description: Digital signature