summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-08-02 22:55:22 -0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-08-02 22:55:22 -0400
commita13ee29b975d3a9a012983309e842d942b2bbd44 (patch)
tree6c4aa2018e61336541a2af4a4bca7eecc7896306
parentgit-gui: Minor refactoring of merge command line in merge support (diff)
downloadtgif-a13ee29b975d3a9a012983309e842d942b2bbd44.tar.xz
git-gui: Avoid Tcl error in popup menu on diff viewer
If there is no path currently shown in the diff viewer then we were getting Tcl errors anytime the user right-clicked on the diff viewer to bring up its popup menu. The bug here is caused by trying to get the file_state for the empty string; this path is never seen so we never have file_state for it. In such cases we now disable the Stage Hunk For Commit option. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui.sh4
1 files changed, 3 insertions, 1 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 671b8873f2..2c7eb3c25c 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2407,13 +2407,15 @@ $ctxm add separator
$ctxm add command -label {Options...} \
-command do_options
proc popup_diff_menu {ctxm x y X Y} {
+ global current_diff_path
set ::cursorX $x
set ::cursorY $y
if {$::ui_index eq $::current_diff_side} {
$ctxm entryconf $::ui_diff_applyhunk \
-state normal \
-label {Unstage Hunk From Commit}
- } elseif {{_O} eq [lindex $::file_states($::current_diff_path) 0]} {
+ } elseif {![info exists file_states($current_diff_path)]
+ || {_O} eq [lindex $file_states($::current_diff_path) 0]} {
$ctxm entryconf $::ui_diff_applyhunk \
-state disabled \
-label {Stage Hunk For Commit}