@matheusbsbs / matheus-bagliano / commits / a13ee29b97
Fork 0

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>

Shawn O. Pearce committed Aug 2, 2007 at 22:55 UTC a13ee29b975d3a9a012983309e842d942b2bbd44
1 file changed +3 -1
git-gui.sh
+3 -1
@@ -2407,13 +2407,15 @@ $ctxm add separator
2407 $ctxm add command -label {Options...} \
2408 -command do_options
2409 proc popup_diff_menu {ctxm x y X Y} {
2410 + global current_diff_path
2411 set ::cursorX $x
2412 set ::cursorY $y
2413 if {$::ui_index eq $::current_diff_side} {
2414 $ctxm entryconf $::ui_diff_applyhunk \
2415 -state normal \
2416 -label {Unstage Hunk From Commit}
2416 - } elseif {{_O} eq [lindex $::file_states($::current_diff_path) 0]} {
2417 + } elseif {![info exists file_states($current_diff_path)]
2418 + || {_O} eq [lindex $file_states($::current_diff_path) 0]} {
2419 $ctxm entryconf $::ui_diff_applyhunk \
2420 -state disabled \
2421 -label {Stage Hunk For Commit}