git-gui: Locate the library directory early during startup
To support a localized version of git-gui we need to locate the library directory early so we can initialize Tcl's msgcat package to load translated messages from. This needs to occur before we declare our git-version proc so that errors related to locating git or assessing its version can be reported to the end-user in their preferred language. However we have to keep the library loading until after git-version has been declared, otherwise we will fail to start git-gui if we are using a fake tclIndex that was generated by our Makefile. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Sep 1, 2007 at 21:58 UTC
fc703c209d415fe20ad5551465b5b68b8ab8b046
1 file changed
+15
-10
git-gui.sh
+15
-10
@@ -42,6 +42,20 @@ if {[catch {package require Tcl 8.4} err]
42
exit 1
43
}
44
45
+######################################################################
46
+##
47
+## locate our library
48
+
49
+set oguilib {@@GITGUI_LIBDIR@@}
50
+set oguirel {@@GITGUI_RELATIVE@@}
51
+if {$oguirel eq {1}} {
52
+ set oguilib [file dirname [file dirname [file normalize $argv0]]]
53
+ set oguilib [file join $oguilib share git-gui lib]
54
+} elseif {[string match @@* $oguirel]} {
55
+ set oguilib [file join [file dirname [file normalize $argv0]] lib]
56
+}
57
+unset oguirel
58
+
59
######################################################################
60
##
61
## enable verbose loading?
@@ -595,15 +609,6 @@ You are using [git-version]:
609
##
610
## configure our library
611
598
-set oguilib {@@GITGUI_LIBDIR@@}
599
-set oguirel {@@GITGUI_RELATIVE@@}
600
-if {$oguirel eq {1}} {
601
- set oguilib [file dirname [file dirname [file normalize $argv0]]]
602
- set oguilib [file join $oguilib share git-gui lib]
603
-} elseif {[string match @@* $oguirel]} {
604
- set oguilib [file join [file dirname [file normalize $argv0]] lib]
605
-}
606
-
612
set idx [file join $oguilib tclIndex]
613
if {[catch {set fd [open $idx r]} err]} {
614
catch {wm withdraw .}
@@ -637,7 +642,7 @@ if {$idx ne {}} {
642
} else {
643
set auto_path [concat [list $oguilib] $auto_path]
644
}
640
-unset -nocomplain oguirel idx fd
645
+unset -nocomplain idx fd
646
647
######################################################################
648
##