Skip to contentSkip to conversation

BUG: gitk fails to parse 1.7.4-rc0 version string

PATCH Applied Mathias Lafeldt 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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:

gitk-git/gitk +0 -1
index e82c6bf..367446e 100644
@@ -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

#1 lore raw

PATCH 1/1 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.

---
 gitk-git/gitk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitk-git/gitk +1 -1
index e82c6bf..9cbc09d 100755
@@ -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} {
Signature · 1 line
1.7.4-rc0
#2 lore raw

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

Quoted 21 lines · Anders Kaseorg

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.

---
 gitk-git/gitk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitk-git/gitk +0 -0
index e82c6bf..9cbc09d 100755

gitk-git/gitk if {![info exists have_ttk]} { · line 11587

Quoted 8 lines
gitk-git/gitk +1 -1
@@ -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

Reviewed-by
#3 lore raw

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

Quoted 4 lines · Mathias Lafeldt
Quoted 2 lines · Anders Kaseorg

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

[...]

Quoted 2 lines

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

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.

#4 lore raw

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

Quoted 10 lines · Jonathan Nieder

[...]
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

OK then. Junio? :)

Quoted 7 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.

#5 lore raw

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

Quoted 7 lines · Mathias Lafeldt
Quoted 6 lines · Jonathan Nieder

[...]
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).

Quoted 6 lines
Quoted 4 lines

Anders's fix looks good to me for robustness reasons anyway, so

OK then. Junio? :)

I'll pick it up.

Paul.

#6 lore raw

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

Quoted 3 lines · Paul Mackerras
Quoted 1 line

OK then. Junio? :)

I'll pick it up.

Thanks.

#7 lore raw

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

In reply to Anders Kaseorg
Quoted 2 lines · Anders Kaseorg

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.