git-gui: require git >= 2.36

git-gui since commit d6967022 explicitly requires version >= 1.5.0, and this coded requirement has never been changed. But, since 0730a5a3a git-gui actually requires git 2.36, providing 'git hook run.' git-gui throws an error if that command is not supported. So, let's update the requirement checking code to 2.36, and throw a more useful error if this is not met. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>

Mark Levedahl committed Feb 12, 2024 at 23:32 UTC 77f648edb69dba164e2e32f33ab009fa33c3d9f1
1 file changed +16 -33
git-gui.sh
+16 -33
@@ -992,6 +992,8 @@ if {$_git eq {}} {
992 ##
993 ## version check
994
995 +set MIN_GIT_VERSION 2.36
996 +
997 if {[catch {set _git_version [git --version]} err]} {
998 catch {wm withdraw .}
999 tk_messageBox \
@@ -1002,9 +1004,10 @@ if {[catch {set _git_version [git --version]} err]} {
1004
1005 $err
1006
1005 -[appname] requires Git 1.5.0 or later."
1007 +[appname] requires Git $MIN_GIT_VERSION or later."
1008 exit 1
1009 }
1010 +
1011 if {![regsub {^git version } $_git_version {} _git_version]} {
1012 catch {wm withdraw .}
1013 tk_messageBox \
@@ -1029,25 +1032,19 @@ proc get_trimmed_version {s} {
1032 set _real_git_version $_git_version
1033 set _git_version [get_trimmed_version $_git_version]
1034
1032 -if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
1033 - catch {wm withdraw .}
1034 - if {[tk_messageBox \
1035 - -icon warning \
1036 - -type yesno \
1037 - -default no \
1038 - -title "[appname]: warning" \
1039 - -message [mc "Git version cannot be determined.
1040 -
1041 -%s claims it is version '%s'.
1042 -
1043 -%s requires at least Git 1.5.0 or later.
1035 +if {[catch {set vcheck [package vcompare $_git_version $MIN_GIT_VERSION]}] ||
1036 + [expr $vcheck < 0] } {
1037
1045 -Assume '%s' is version 1.5.0?
1046 -" $_git $_real_git_version [appname] $_real_git_version]] eq {yes}} {
1047 - set _git_version 1.5.0
1048 - } else {
1049 - exit 1
1050 - }
1038 + set msg1 [mc "Insufficient git version, require: "]
1039 + set msg2 [mc "git returned:"]
1040 + set message "$msg1 $MIN_GIT_VERSION\n$msg2 $_real_git_version"
1041 + catch {wm withdraw .}
1042 + tk_messageBox \
1043 + -icon error \
1044 + -type ok \
1045 + -title [mc "git-gui: fatal error"] \
1046 + -message $message
1047 + exit 1
1048 }
1049 unset _real_git_version
1050
@@ -1095,20 +1092,6 @@ proc git-version {args} {
1092 }
1093 }
1094
1098 -if {[git-version < 1.5]} {
1099 - catch {wm withdraw .}
1100 - tk_messageBox \
1101 - -icon error \
1102 - -type ok \
1103 - -title [mc "git-gui: fatal error"] \
1104 - -message "[appname] requires Git 1.5.0 or later.
1105 -
1106 -You are using [git-version]:
1107 -
1108 -[git --version]"
1109 - exit 1
1110 -}
1111 -
1095 ######################################################################
1096 ##
1097 ## configure our library