@matheusbsbs / matheus-bagliano / commits / 67112c484b
Fork 0

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>

Pat Thoyts committed Oct 7, 2010 at 22:28 UTC 67112c484b5d460ccceb54f3a32b62e4e6e705f0
1 file changed +12 -5
git-gui.sh
+12 -5
@@ -878,12 +878,19 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
878 exit 1
879 }
880
881 +proc get_trimmed_version {s} {
882 + set r {}
883 + foreach x [split $s -._] {
884 + if {[string is integer -strict $x]} {
885 + lappend r $x
886 + } else {
887 + break
888 + }
889 + }
890 + return [join $r .]
891 +}
892 set _real_git_version $_git_version
882 -regsub -- {[\-\.]dirty$} $_git_version {} _git_version
883 -regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
884 -regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
885 -regsub {\.GIT$} $_git_version {} _git_version
886 -regsub {\.[a-zA-Z]+\.?[0-9]+$} $_git_version {} _git_version
893 +set _git_version [get_trimmed_version $_git_version]
894
895 if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
896 catch {wm withdraw .}