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

8 messages from 2011-01-04 to 2011-01-19. Participants: Mathias Lafeldt, Anders Kaseorg, Jonathan Nieder, Paul Mackerras, Junio C Hamano.
Thread: https://gitlist.dev/t/26186

## Mathias Lafeldt, 2011-01-04 12:44

Subject: BUG: gitk fails to parse 1.7.4-rc0 version string
Message-ID: <4D231646.5080005@debugon.org>
URL: https://gitlist.dev/e/4D231646.5080005%40debugon.org

```
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, 2011-01-07 00:42

Subject: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <1294360953.21006.2.camel@fixed-disk>
URL: https://gitlist.dev/e/1294360953.21006.2.camel%40fixed-disk
In-Reply-To: <4D231646.5080005@debugon.org>

```
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, 2011-01-11 13:46

Subject: Re: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <4D2C5F3E.2020007@debugon.org>
URL: https://gitlist.dev/e/4D2C5F3E.2020007%40debugon.org
In-Reply-To: <1294360953.21006.2.camel@fixed-disk>

```
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"
> 
> 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, 2011-01-13 19:22

Subject: Re: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <20110113192243.GA20625@burratino>
URL: https://gitlist.dev/e/20110113192243.GA20625%40burratino
In-Reply-To: <4D2C5F3E.2020007@debugon.org>

```
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, 2011-01-18 09:12

Subject: Re: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <4D355966.7090707@debugon.org>
URL: https://gitlist.dev/e/4D355966.7090707%40debugon.org
In-Reply-To: <20110113192243.GA20625@burratino>

```
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? :)

> 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, 2011-01-18 10:47

Subject: Re: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <20110118104742.GA3279@brick.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20110118104742.GA3279%40brick.ozlabs.ibm.com
In-Reply-To: <4D355966.7090707@debugon.org>

```
On Tue, Jan 18, 2011 at 10:12:06AM +0100, Mathias Lafeldt wrote:
> 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.

```

## Junio C Hamano, 2011-01-18 21:26

Subject: Re: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <7voc7dkink.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7voc7dkink.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20110118104742.GA3279@brick.ozlabs.ibm.com>

```
Paul Mackerras <paulus@samba.org> writes:

>> OK then. Junio? :)
>
> I'll pick it up.

Thanks.

```

## Paul Mackerras, 2011-01-19 09:35

Subject: Re: [PATCH] gitk: Take only numeric version components when computing $git_version
Message-ID: <20110119093518.GB5728@brick.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20110119093518.GB5728%40brick.ozlabs.ibm.com
In-Reply-To: <1294360953.21006.2.camel@fixed-disk>

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

```
