@matheusbsbs / matheus-bagliano / commits / 301dfaa9da
Fork 0

git-gui: Let the user continue even if we cannot understand git version

Some users may do odd things, like tag their own private version of Git with an annotated tag such as 'testver', then compile that git and try to use it with git-gui. In such a case `git --version` will give us 'git version testver', which is not a numeric argument that we can pass off to our version comparsion routine. We now check that the cleaned up git version is a going to pass the version comparsion routine without failure. If it has a non-numeric component, or lacks at least a minor revision then we ask the user to confirm they really want to use this version of git within git-gui. If they do we shall assume it is git 1.5.0 and run with only the code that will support. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jul 17, 2007 at 23:09 UTC 301dfaa9daeb64c66d616efe50fac29d542c9414
1 file changed +27
git-gui.sh
+27
@@ -547,11 +547,35 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
547 error_popup "Cannot parse Git version string:\n\n$_git_version"
548 exit 1
549 }
550 +
551 +set _real_git_version $_git_version
552 regsub -- {-dirty$} $_git_version {} _git_version
553 regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
554 regsub {\.rc[0-9]+$} $_git_version {} _git_version
555 regsub {\.GIT$} $_git_version {} _git_version
556
557 +if {![regexp {^[1-9]+(\.[0-9]+)+$} $_git_version]} {
558 + catch {wm withdraw .}
559 + if {[tk_messageBox \
560 + -icon warning \
561 + -type yesno \
562 + -default no \
563 + -title "[appname]: warning" \
564 + -message "Git version cannot be determined.
565 +
566 +$_git claims it is version '$_real_git_version'.
567 +
568 +[appname] requires at least Git 1.5.0 or later.
569 +
570 +Assume '$_real_git_version' is version 1.5.0?
571 +"] eq {yes}} {
572 + set _git_version 1.5.0
573 + } else {
574 + exit 1
575 + }
576 +}
577 +unset _real_git_version
578 +
579 proc git-version {args} {
580 global _git_version
581
@@ -2586,4 +2610,7 @@ Compress the database now?"] eq yes} {
2610 }
2611
2612 lock_index begin-read
2613 +if {![winfo ismapped .]} {
2614 + wm deiconify .
2615 +}
2616 after 1 do_rescan