Skip to contentSkip to conversation

perf tool: fix the perf --version bug

PATCH In review Runzhen Wang 1 participant 2 messages Apr 16, 2013 – Apr 24, 2013 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tool: fix the perf --version bug

From 4d629cfb265beece1aae2e3fdf603e36a321f785 Mon Sep 17 00:00:00 2001
From: Runzhen Wang <[email protected]>
Date: Mon, 15 Apr 2013 23:17:15 -0400
Subject: [PATCH] perf tool: fix the perf --version bug

The perf --version can't print the right version
information when reset it to an earlier commit.

For example, at present the version is:

# ./perf --version
perf version 3.9.rc6.gf8378f

then, I reset it to an earlier version, say v3.8-rc7

# git reset --hard v3.8-rc7
# make

However, the ./perf --version prints a wrong result:

# ./perf --version
perf version 3.9.rc6.g836dc9

Using 'git describe' instead of 'git tag' can fix this problem.

---
 tools/perf/util/PERF-VERSION-GEN |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/PERF-VERSION-GEN +1 -2
index 055fef3..ec3dd86 100755
@@ -14,9 +14,8 @@ LF='
 # otherwise try to get the version from the kernel Makefile
 #
 if test -d ../../.git -o -f ../../.git &&
-    VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*")
+    VN=$(git describe --match 'v[0-9].[0-9]*' --abbrev=4 HEAD 2>/dev/null)
 then
-    VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD))
     VN=$(echo "$VN" | sed -e 's/-/./g');
 else
     VN=$(MAKEFLAGS= make -sC ../.. kernelversion)
Signature · 1 line
1.7.10.1
#1 lore raw

ping~ :)

Quoted 39 lines · Runzhen Wang

The perf --version can't print the right version
information when reset it to an earlier commit.

For example, at present the version is:

# ./perf --version
perf version 3.9.rc6.gf8378f

then, I reset it to an earlier version tag, say v3.8-rc7

# git reset --hard v3.8-rc7
# make

However, the ./perf --version prints a wrong result:

# ./perf --version
perf version 3.9.rc6.g836dc9

Using 'git describe' instead of 'git tag' can fix this problem.

---
  tools/perf/util/PERF-VERSION-GEN |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/PERF-VERSION-GEN +1 -2
index 055fef3..ec3dd86 100755
@@ -14,9 +14,8 @@ LF='
  # otherwise try to get the version from the kernel Makefile
  #
  if test -d ../../.git -o -f ../../.git &&
-    VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*")
+    VN=$(git describe --match 'v[0-9].[0-9]*' --abbrev=4 HEAD 2>/dev/null)
  then
-    VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD))
      VN=$(echo "$VN" | sed -e 's/-/./g');
  else
      VN=$(MAKEFLAGS= make -sC ../.. kernelversion)