linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Fix perf version generation
@ 2013-05-08  9:43 Robert Richter
  2013-05-08 10:39 ` Xiao Guangrong
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Robert Richter @ 2013-05-08  9:43 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, Robert Richter

From: Robert Richter <robert.richter@calxeda.com>

The tag of the perf version is wrongly determined, always the latest
tag is taken regardless of the HEAD commit:

 $ perf --version
 perf version 3.9.rc8.gd7f5d3
 $ git describe d7f5d3
 v3.9-rc7-154-gd7f5d33
 $ head -n 4 Makefile
 VERSION = 3
 PATCHLEVEL = 9
 SUBLEVEL = 0
 EXTRAVERSION = -rc7

In other cases no tag might be found.

This patch fixes this.

This new implementation handles also the case if there are no tags at
all found in the git repo but there is a commit id.

Signed-off-by: Robert Richter <robert.richter@calxeda.com>
---
 tools/perf/util/PERF-VERSION-GEN | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
index 055fef3..15a77b7 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/perf/util/PERF-VERSION-GEN
@@ -13,13 +13,22 @@ LF='
 # First check if there is a .git to get the version from git describe
 # 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]*")
+CID=
+TAG=
+if test -d ../../.git -o -f ../../.git
 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)
+	TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
+	CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
+fi
+if test -z "$TAG"
+then
+	TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
+fi
+VN="$TAG$CID"
+if test -n "$CID"
+then
+	# format version string, strip trailing zero of sublevel:
+	VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/')
 fi
 
 VN=$(expr "$VN" : v*'\(.*\)')
-- 
1.8.1.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf tools: Fix perf version generation
  2013-05-08  9:43 [PATCH] perf tools: Fix perf version generation Robert Richter
@ 2013-05-08 10:39 ` Xiao Guangrong
  2013-05-08 11:06   ` Robert Richter
  2013-07-01  8:24 ` Borislav Petkov
  2013-07-12  8:52 ` [tip:perf/urgent] " tip-bot for Robert Richter
  2 siblings, 1 reply; 7+ messages in thread
From: Xiao Guangrong @ 2013-05-08 10:39 UTC (permalink / raw)
  To: Robert Richter
  Cc: Arnaldo Carvalho de Melo, linux-kernel, Robert Richter,
	SH-Run Zhen RZ Wang

On 05/08/2013 05:43 PM, Robert Richter wrote:
> From: Robert Richter <robert.richter@calxeda.com>
> 
> The tag of the perf version is wrongly determined, always the latest
> tag is taken regardless of the HEAD commit:
> 
>  $ perf --version
>  perf version 3.9.rc8.gd7f5d3
>  $ git describe d7f5d3
>  v3.9-rc7-154-gd7f5d33
>  $ head -n 4 Makefile
>  VERSION = 3
>  PATCHLEVEL = 9
>  SUBLEVEL = 0
>  EXTRAVERSION = -rc7
> 
> In other cases no tag might be found.
> 
> This patch fixes this.
> 
> This new implementation handles also the case if there are no tags at
> all found in the git repo but there is a commit id.

I remember that Wang has posted a similar patch to fix this bug several
weeks ago:
	http://lkml.org/lkml/2013/4/24/70

But have no response yet.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf tools: Fix perf version generation
  2013-05-08 10:39 ` Xiao Guangrong
@ 2013-05-08 11:06   ` Robert Richter
  2013-05-08 14:01     ` Runzhen Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Richter @ 2013-05-08 11:06 UTC (permalink / raw)
  To: Xiao Guangrong
  Cc: Arnaldo Carvalho de Melo, linux-kernel, SH-Run Zhen RZ Wang

On 08.05.13 18:39:07, Xiao Guangrong wrote:
> I remember that Wang has posted a similar patch to fix this bug several
> weeks ago:
> 	http://lkml.org/lkml/2013/4/24/70
> 
> But have no response yet.

Yes, this patch would fix the version tag too.

The patch I wrote also reports a commit id even in the case when no
tag is found. This was the original reason why I stumbled over this.
Assume a repository for testing there you just push the commit id to.
This does not contain any tags but a valid commit id. Now, it
determines the version tag from the makefile but does not drop the
commit id.

-Robert

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf tools: Fix perf version generation
  2013-05-08 11:06   ` Robert Richter
@ 2013-05-08 14:01     ` Runzhen Wang
  2013-05-10  9:09       ` Robert Richter
  0 siblings, 1 reply; 7+ messages in thread
From: Runzhen Wang @ 2013-05-08 14:01 UTC (permalink / raw)
  To: Robert Richter
  Cc: Xiao Guangrong, Arnaldo Carvalho de Melo, linux-kernel, mingo

On 05/08/2013 07:06 PM, Robert Richter wrote:
> On 08.05.13 18:39:07, Xiao Guangrong wrote:
I remember that Wang has posted a similar patch to fix this bug several
>> weeks ago:
http://lkml.org/lkml/2013/4/24/70
>>
>> But have no response yet.
>
> Yes, this patch would fix the version tag too.
>
> The patch I wrote also reports a commit id even in the case when no
> tag is found. This was the original reason why I stumbled over this.
> Assume a repository for testing there you just push the commit id to.
> This does not contain any tags but a valid commit id. Now, it
> determines the version tag from the makefile but does not drop the
> commit id.
>
> -Robert
>
Hi, Robert,

for http://lkml.org/lkml/2013/4/24/70
I download linux-3.9.1.tar.xz(no git repo) and apply my patch, it works:

# ./perf --version
perf version 3.9.1

your patch works when the repo only has commit info but no tags info, 
but I confuse that whether this situation is Real?

Maybe you prepare for a RARE case but increase the code's **Complexity** ?

thanks


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf tools: Fix perf version generation
  2013-05-08 14:01     ` Runzhen Wang
@ 2013-05-10  9:09       ` Robert Richter
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Richter @ 2013-05-10  9:09 UTC (permalink / raw)
  To: Runzhen Wang
  Cc: Xiao Guangrong, Arnaldo Carvalho de Melo, linux-kernel, mingo

On 08.05.13 22:01:01, Runzhen Wang wrote:
> # ./perf --version
> perf version 3.9.1
> 
> your patch works when the repo only has commit info but no tags
> info, but I confuse that whether this situation is Real?
> 
> Maybe you prepare for a RARE case but increase the code's **Complexity** ?

It works in both cases. And the complexity is also handled for kernel
versioning, see scripts/setlocalversion:

 # If we don't have a tag at all we print -g{commitish}.

I also considered to reuse scripts/setlocalversion, but it turned out
to require too much changes for perf version generation.

-Robert

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf tools: Fix perf version generation
  2013-05-08  9:43 [PATCH] perf tools: Fix perf version generation Robert Richter
  2013-05-08 10:39 ` Xiao Guangrong
@ 2013-07-01  8:24 ` Borislav Petkov
  2013-07-12  8:52 ` [tip:perf/urgent] " tip-bot for Robert Richter
  2 siblings, 0 replies; 7+ messages in thread
From: Borislav Petkov @ 2013-07-01  8:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Robert Richter, Arnaldo Carvalho de Melo, linux-kernel, Robert Richter

Hey acme,

is this one in some queue already?

I just saw the same problem on 3.10 because git-tag sorts the output
alphanumerically so that all tags starting with "v3.10" do not appear
last and thus the "tail -1" doesn't work anymore.

So on 3.10 you end up with perf version 3.9.rc8.g8bb495.

On Wed, May 08, 2013 at 11:43:34AM +0200, Robert Richter wrote:
> From: Robert Richter <robert.richter@calxeda.com>
> 
> The tag of the perf version is wrongly determined, always the latest
> tag is taken regardless of the HEAD commit:
> 
>  $ perf --version
>  perf version 3.9.rc8.gd7f5d3
>  $ git describe d7f5d3
>  v3.9-rc7-154-gd7f5d33
>  $ head -n 4 Makefile
>  VERSION = 3
>  PATCHLEVEL = 9
>  SUBLEVEL = 0
>  EXTRAVERSION = -rc7
> 
> In other cases no tag might be found.
> 
> This patch fixes this.
> 
> This new implementation handles also the case if there are no tags at
> all found in the git repo but there is a commit id.
> 
> Signed-off-by: Robert Richter <robert.richter@calxeda.com>
> ---
>  tools/perf/util/PERF-VERSION-GEN | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
> index 055fef3..15a77b7 100755
> --- a/tools/perf/util/PERF-VERSION-GEN
> +++ b/tools/perf/util/PERF-VERSION-GEN
> @@ -13,13 +13,22 @@ LF='
>  # First check if there is a .git to get the version from git describe
>  # 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]*")
> +CID=
> +TAG=
> +if test -d ../../.git -o -f ../../.git
>  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)
> +	TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
> +	CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
> +fi
> +if test -z "$TAG"
> +then
> +	TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
> +fi
> +VN="$TAG$CID"
> +if test -n "$CID"
> +then
> +	# format version string, strip trailing zero of sublevel:
> +	VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/')
>  fi
>  
>  VN=$(expr "$VN" : v*'\(.*\)')
> -- 
> 1.8.1.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/urgent] perf tools: Fix perf version generation
  2013-05-08  9:43 [PATCH] perf tools: Fix perf version generation Robert Richter
  2013-05-08 10:39 ` Xiao Guangrong
  2013-07-01  8:24 ` Borislav Petkov
@ 2013-07-12  8:52 ` tip-bot for Robert Richter
  2 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Robert Richter @ 2013-07-12  8:52 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, mingo, tglx, robert.richter

Commit-ID:  a4147f0f91386540316e468f3a3674a498dada5f
Gitweb:     http://git.kernel.org/tip/a4147f0f91386540316e468f3a3674a498dada5f
Author:     Robert Richter <robert.richter@calxeda.com>
AuthorDate: Wed, 8 May 2013 11:43:34 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 8 Jul 2013 18:09:52 -0300

perf tools: Fix perf version generation

The tag of the perf version is wrongly determined, always the latest tag
is taken regardless of the HEAD commit:

 $ perf --version
 perf version 3.9.rc8.gd7f5d3
 $ git describe d7f5d3
 v3.9-rc7-154-gd7f5d33
 $ head -n 4 Makefile
 VERSION = 3
 PATCHLEVEL = 9
 SUBLEVEL = 0
 EXTRAVERSION = -rc7

In other cases no tag might be found.

This patch fixes this.

This new implementation handles also the case if there are no tags at
all found in the git repo but there is a commit id.

Signed-off-by: Robert Richter <robert.richter@calxeda.com>
Link: http://lkml.kernel.org/r/1368006214-12912-1-git-send-email-rric@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/PERF-VERSION-GEN | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
index 055fef3..15a77b7 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/perf/util/PERF-VERSION-GEN
@@ -13,13 +13,22 @@ LF='
 # First check if there is a .git to get the version from git describe
 # 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]*")
+CID=
+TAG=
+if test -d ../../.git -o -f ../../.git
 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)
+	TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
+	CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
+fi
+if test -z "$TAG"
+then
+	TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
+fi
+VN="$TAG$CID"
+if test -n "$CID"
+then
+	# format version string, strip trailing zero of sublevel:
+	VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/')
 fi
 
 VN=$(expr "$VN" : v*'\(.*\)')

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-07-12  8:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-08  9:43 [PATCH] perf tools: Fix perf version generation Robert Richter
2013-05-08 10:39 ` Xiao Guangrong
2013-05-08 11:06   ` Robert Richter
2013-05-08 14:01     ` Runzhen Wang
2013-05-10  9:09       ` Robert Richter
2013-07-01  8:24 ` Borislav Petkov
2013-07-12  8:52 ` [tip:perf/urgent] " tip-bot for Robert Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).