Skip to content

Commit 67112c4

Browse files
committed
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 <[email protected]>
1 parent c0d2c38 commit 67112c4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

git-gui.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,19 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
878878
exit 1
879879
}
880880
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+
}
881892
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]
887894
888895
if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
889896
catch {wm withdraw .}

0 commit comments

Comments
 (0)