git-gui: Basic version check to ensure git 1.5.0 or later is used.
authorShawn O. Pearce <spearce@spearce.org>
Wed, 14 Feb 2007 04:15:25 +0000 (23:15 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 14 Feb 2007 04:15:25 +0000 (23:15 -0500)
This is a very crude (but hopefully effective) check against the
`git` executable found in our PATH. Some of the subcommands and
options that git-gui requires to be present to operate were created
during the 1.5.0 development cycle, so 1.5 is the minimum version
of git that we can expect to support.

There actually are early releases of 1.5 (e.g. 1.5.0-rc0) that
don't have everything we expect (like `blame --incremental`) but
these are purely academic at this point. 1.5.0 final was tagged
and released just a few hours ago. The release candidates will
(hopefully) fade into the dark quickly.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui.sh
index 7ecb98b900576ed6abc8b4e4af4333a209769ba6..444cc0afc8bbae74c78289fabca9855f7777addc 100755 (executable)
@@ -295,6 +295,38 @@ proc ask_popup {msg} {
                -message $msg]
 }
 
+######################################################################
+##
+## version check
+
+set req_maj 1
+set req_min 5
+
+if {[catch {set v [git --version]} err]} {
+       catch {wm withdraw .}
+       error_popup "Cannot determine Git version:
+
+$err
+
+[appname] requires Git $req_maj.$req_min or later."
+       exit 1
+}
+if {[regexp {^git version (\d+)\.(\d+)} $v _junk act_maj act_min]} {
+       if {$act_maj < $req_maj
+               || ($act_maj == $req_maj && $act_min < $req_min)} {
+               catch {wm withdraw .}
+               error_popup "[appname] requires Git $req_maj.$req_min or later.
+
+You are using $v."
+               exit 1
+       }
+} else {
+       catch {wm withdraw .}
+       error_popup "Cannot parse Git version string:\n\n$v"
+       exit 1
+}
+unset -nocomplain v _junk act_maj act_min req_maj req_min
+
 ######################################################################
 ##
 ## repository setup