Skip to content

Commit

Permalink
git-gui: generic version trimming
Browse files Browse the repository at this point in the history
Rather than attempting to trim off all the non-version number suffixes
from the 'git version' result, let us scan along from the beginning until
we find a non-numeric part and stop there. Any such dot-version number will
be compatible with the Tcl package version comparison command which is the
aim of this code.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
  • Loading branch information
Pat Thoyts committed Oct 7, 2010
1 parent c0d2c38 commit 67112c4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -878,12 +878,19 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
exit 1
}
proc get_trimmed_version {s} {
set r {}
foreach x [split $s -._] {
if {[string is integer -strict $x]} {
lappend r $x
} else {
break
}
}
return [join $r .]
}
set _real_git_version $_git_version
regsub -- {[\-\.]dirty$} $_git_version {} _git_version
regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
regsub {\.GIT$} $_git_version {} _git_version
regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
set _git_version [get_trimmed_version $_git_version]
if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
catch {wm withdraw .}
Expand Down

0 comments on commit 67112c4

Please sign in to comment.