summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPat Thoyts <patthoyts@users.sourceforge.net>2010-10-07 22:28:45 +0100
committerPat Thoyts <patthoyts@users.sourceforge.net>2010-10-07 22:28:45 +0100
commit67112c484b5d460ccceb54f3a32b62e4e6e705f0 (patch)
tree03816549c1324908c776edcab8bfb3ba984b2650
parentc0d2c38d78fc3b55b7f0a2470ca89bed43eb4019 (diff)
downloadgit-67112c484b5d460ccceb54f3a32b62e4e6e705f0.tar.gz
git-gui: generic version trimming
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>
-rwxr-xr-xgit-gui.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/git-gui.sh b/git-gui.sh
index ea262a2bac..25229a4073 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -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 .}