[PATCH v2] kbuild: tag with git revision when git describe is missing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



setlocalversion used to use an abbreviated git commit sha1 to generate the
tag.  This was changed in commit d882421f4e08ddf0a94245cdbe516db260aa6f41
"kbuild: change CONFIG_LOCALVERSION_AUTO to use a git-describe-ish format"
to use git describe to come up with a tag.  Which is nice, but git describe
sometimes can't describe the revision.  Commit
56b2f0706d82535fd8d85503f2dcc0be40c8e55d addressed this, but there is still
no tag generated.

So, generate a plain abbreviated sha1 tag like setlocalversion used to when
git describe comes up short.

Signed-off-by: Trent Piepho <tpiepho@xxxxxxxxxxxxx>
CC: Jan Engelhardt <jengelh@xxxxxxxxxx>
CC: Sam Ravnborg <sam@xxxxxxxxxxxx>
---
 scripts/setlocalversion |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 83b7512..0de5a99 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -9,11 +9,13 @@ usage() {
 cd "${1:-.}" || usage
 
 # Check for git and a git repo.
-if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+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
 	fi
 
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux