Skip to content

Commit

Permalink
git-gui: Avoid Tcl error in popup menu on diff viewer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
spearce committed Aug 3, 2007
1 parent 84f6753 commit a13ee29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit a13ee29

Please sign in to comment.