threads / bug / 26186

BUG: gitk fails to parse 1.7.4-rc0 version string

Subject: BUG: gitk fails to parse 1.7.4-rc0 version string

## tl;dr

8 messages between Jan 4, 2011 and Jan 19, 2011.

replies: 7people: 5as markdown or json

Mathias Lafeldt· Jan 4, 2011, 12:44 UTC · lore
Looks like gitk doesn't like the "-rc0" suffix.

$ git --version git version 1.7.4-rc0

$ gitk
Error in startup script: expected version number but got "1.7.4-rc0"
    while executing
"package vcompare $git_version "1.6.6.2""
    (file "/usr/local/bin/gitk" line 1)
I temporarily fixed it by hard-coding the version string:
diff --git a/gitk-git/gitk b/gitk-git/gitk
index e82c6bf..367446e 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -11581,7 +11581,7 @@ if {![info exists have_ttk]} {
 set use_ttk [expr {$have_ttk && $want_ttk}]
 set NS [expr {$use_ttk ? "ttk" : ""}]

-set git_version [join [lrange [split [lindex [exec git version] end] .]
0 2] .]
+set git_version "1.7.4"


 set show_notes {}
 if {[package vcompare $git_version "1.6.6.2"] >= 0} {


-Mathias
Anders Kaseorg· Jan 7, 2011, 00:42 UTC · re: Mathias Lafeldt · lore

[PATCH] gitk: Take only numeric version components when computing $git_version

This fixes errors running with release candidate versions of Git:
  Error in startup script: expected version number but got "1.7.4-rc0"

Also, $git_version is no longer artificially limited to three components. That limitation was added by commit 194bbf6cc8c2f3c14a920c841841d66b7667a848 to deal with msysGit version strings like “1.6.4.msysgit.0”, and we don’t need it now. Hence as another side effect, this enables showing notes with git version 1.6.6.2 or 1.6.6.3, as originally intended by commit 7defefb134270b6e8ab3e422b343b41a4a383f5d.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
 gitk-git/gitk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index e82c6bf..9cbc09d 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -11581,7 +11581,7 @@ if {![info exists have_ttk]} {
 set use_ttk [expr {$have_ttk && $want_ttk}]
 set NS [expr {$use_ttk ? "ttk" : ""}]
 
-set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]
+regexp {^git version ([\d.]*\d)} [exec git version] _ git_version
 
 set show_notes {}
 if {[package vcompare $git_version "1.6.6.2"] >= 0} {
-- 
1.7.4-rc0
Mathias Lafeldt· Jan 11, 2011, 13:46 UTC · re: Anders Kaseorg · lore

Re: [PATCH] gitk: Take only numeric version components when computing $git_version

Anders Kaseorg wrote:
Show 29 quoted lines
> This fixes errors running with release candidate versions of Git:
>   Error in startup script: expected version number but got "1.7.4-rc0"
> 
> Also, $git_version is no longer artificially limited to three
> components.  That limitation was added by commit
> 194bbf6cc8c2f3c14a920c841841d66b7667a848 to deal with msysGit version
> strings like “1.6.4.msysgit.0”, and we don’t need it now.  Hence as
> another side effect, this enables showing notes with git version
> 1.6.6.2 or 1.6.6.3, as originally intended by commit
> 7defefb134270b6e8ab3e422b343b41a4a383f5d.
> 
> Signed-off-by: Anders Kaseorg <andersk@mit.edu>
> ---
>  gitk-git/gitk |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index e82c6bf..9cbc09d 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -11581,7 +11581,7 @@ if {![info exists have_ttk]} {
>  set use_ttk [expr {$have_ttk && $want_ttk}]
>  set NS [expr {$use_ttk ? "ttk" : ""}]
>  
> -set git_version [join [lrange [split [lindex [exec git version] end] .] 0 2] .]
> +regexp {^git version ([\d.]*\d)} [exec git version] _ git_version
>  
>  set show_notes {}
>  if {[package vcompare $git_version "1.6.6.2"] >= 0} {
Seems to work well.
However, an "Reported-by" would have been nice.

People don't seem to use gitk with the RC releases because nobody else complains...

-Mathias
Jonathan Nieder· Jan 13, 2011, 19:22 UTC · re: Mathias Lafeldt · lore

Re: [PATCH] gitk: Take only numeric version components when computing $git_version

Mathias Lafeldt wrote:
> Anders Kaseorg wrote:
>> This fixes errors running with release candidate versions of Git:
>>   Error in startup script: expected version number but got "1.7.4-rc0"
[...]
> People don't seem to use gitk with the RC releases because nobody else
> complains...
GIT-VERSION-GEN contains:
	DEF_VER=v1.7.4-rc1
	[...]
	if test -f version
	then
		[...]
	elif test -d .git -o -f .git &&
		[...]
	then
		VN=$(echo "$VN" | sed -e 's/-/./g');
	else
		VN="$DEF_VER"
	fi

So after building from a tarball generated with "git archive", "git version" produces v1.7.4-rc1, producing errors from gitk, but after building from the git repo or a tarball generated with "make dist", the version is v1.7.4.rc1 (which gitk accepts).

Anders's fix looks good to me for robustness reasons anyway, so
 Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Maybe the substitution in GIT-VERSION-GEN should say something like
		VN=$(echo "$VN" | sed -e 's/-\([^r]\)/.\1/g')

meaning the result for tagged rcs would not depend on whether git is present? Alternatively, DEF_VER could be set to v1.7.4.rc1, which does not seem as nice to me.

Mathias Lafeldt· Jan 18, 2011, 09:12 UTC · re: Jonathan Nieder · lore

Re: [PATCH] gitk: Take only numeric version components when computing $git_version

Jonathan Nieder wrote:
Show 10 quoted lines
> [...]
> So after building from a tarball generated with "git archive", "git version"
> produces v1.7.4-rc1, producing errors from gitk, but after building
> from the git repo or a tarball generated with "make dist", the version
> is v1.7.4.rc1 (which gitk accepts).
> 
> Anders's fix looks good to me for robustness reasons anyway, so
> 
>  Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
> 
OK then. Junio? :)
Show 7 quoted lines
> Maybe the substitution in GIT-VERSION-GEN should say something like
> 
> 		VN=$(echo "$VN" | sed -e 's/-\([^r]\)/.\1/g')
> 
> meaning the result for tagged rcs would not depend on whether git is
> present?  Alternatively, DEF_VER could be set to v1.7.4.rc1, which
> does not seem as nice to me.
Paul Mackerras· Jan 18, 2011, 10:47 UTC · re: Mathias Lafeldt · lore

Re: [PATCH] gitk: Take only numeric version components when computing $git_version

On Tue, Jan 18, 2011 at 10:12:06AM +0100, Mathias Lafeldt wrote:
Show 13 quoted lines
> Jonathan Nieder wrote:
> > [...]
> > So after building from a tarball generated with "git archive", "git version"
> > produces v1.7.4-rc1, producing errors from gitk, but after building
> > from the git repo or a tarball generated with "make dist", the version
> > is v1.7.4.rc1 (which gitk accepts).
> > 
> > Anders's fix looks good to me for robustness reasons anyway, so
> > 
> >  Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
> > 
> 
> OK then. Junio? :)
I'll pick it up.
Paul.
Paul Mackerras· Jan 19, 2011, 09:35 UTC · re: Anders Kaseorg · lore

Re: [PATCH] gitk: Take only numeric version components when computing $git_version

On Thu, Jan 06, 2011 at 05:42:33PM -0700, Anders Kaseorg wrote:
> This fixes errors running with release candidate versions of Git:
>   Error in startup script: expected version number but got "1.7.4-rc0"
Thanks, applied.
Junio, you could do a pull from my gitk repository at your convenience.
Paul.

← back to recent threads