Code

git-gui: Gracefully handle bad TCL_PATH at compile time
[git.git] / git-gui.sh
index 2fda4c229022b19c517228a2c14942dd92b06474..0a471a5c7d4a2126f1f3322424a643796e1de715 100755 (executable)
@@ -28,7 +28,34 @@ set oguilib {@@GITGUI_LIBDIR@@}
 if {[string match @@* $oguilib]} {
        set oguilib [file join [file dirname [file normalize $argv0]] lib]
 }
-set auto_path [concat [list $oguilib] $auto_path]
+set idx [file join $oguilib tclIndex]
+catch {
+       set fd [open $idx r]
+       if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
+               set idx [list]
+               while {[gets $fd n] >= 0} {
+                       if {$n ne {} && ![string match #* $n]} {
+                               lappend idx $n
+                       }
+               }
+       } else {
+               set idx {}
+       }
+       close $fd
+}
+if {$idx ne {}} {
+       set loaded [list]
+       foreach p $idx {
+               if {[lsearch -exact $loaded $p] >= 0} continue
+               puts $p
+               source [file join $oguilib $p]
+               lappend loaded $p
+       }
+       unset loaded p
+} else {
+       set auto_path [concat [list $oguilib] $auto_path]
+}
+unset -nocomplain fd idx
 
 if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
        unset _verbose