git-gui: Provide fatal error if library is unavailable
If we cannot locate our git-gui library directory, or we find it but the tclIndex file is not present there (or it is present but is not something we are allowed to read) the user cannot use the application. Rather than silently ignoring the errors related to the tclIndex file being unavailable we report them up front and display to the user why we cannot start. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
cd12901b8f
commit
f837170663
35
git-gui.sh
35
git-gui.sh
@ -50,26 +50,33 @@ if {$oguirel eq {1}} {
|
|||||||
} elseif {[string match @@* $oguirel]} {
|
} elseif {[string match @@* $oguirel]} {
|
||||||
set oguilib [file join [file dirname [file normalize $argv0]] lib]
|
set oguilib [file join [file dirname [file normalize $argv0]] lib]
|
||||||
}
|
}
|
||||||
|
|
||||||
set idx [file join $oguilib tclIndex]
|
set idx [file join $oguilib tclIndex]
|
||||||
catch {
|
if {[catch {set fd [open $idx r]} err]} {
|
||||||
set fd [open $idx r]
|
catch {wm withdraw .}
|
||||||
if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
|
tk_messageBox \
|
||||||
set idx [list]
|
-icon error \
|
||||||
while {[gets $fd n] >= 0} {
|
-type ok \
|
||||||
if {$n ne {} && ![string match #* $n]} {
|
-title "git-gui: fatal error" \
|
||||||
lappend idx $n
|
-message $err
|
||||||
}
|
exit 1
|
||||||
}
|
|
||||||
} else {
|
|
||||||
set idx {}
|
|
||||||
}
|
|
||||||
close $fd
|
|
||||||
}
|
}
|
||||||
|
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 {}} {
|
if {$idx ne {}} {
|
||||||
set loaded [list]
|
set loaded [list]
|
||||||
foreach p $idx {
|
foreach p $idx {
|
||||||
if {[lsearch -exact $loaded $p] >= 0} continue
|
if {[lsearch -exact $loaded $p] >= 0} continue
|
||||||
puts $p
|
|
||||||
source [file join $oguilib $p]
|
source [file join $oguilib $p]
|
||||||
lappend loaded $p
|
lappend loaded $p
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user