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

git-gui: Paper bag fix "Stage Hunk For Commit" in diff context menu

In a13ee29b975d3a9a012983309e842d942b2bbd44 I totally broke the "Stage Hunk For Commit" feature by making this menu item always appear in a disabled state, so it was never invokable. A "teaser feature", just sitting there taunting the poor user who has become used to having it available. The issue caused by a13ee was I added a test to look at the data in $file_states, but I didn't do that test correctly as it was always looking at a procedure local $file_states array, which is not defined, so the test was always true and we always disabled the menu entry. Instead we only want to disable the menu entry if the current file we are looking at has no file state information (git-gui is just a very confused little process) or it is an untracked file (and we cannot stage individual hunks). Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Aug 21, 2007 at 02:22 UTC ce015c213fbef39140b6192db28110bc666dc6c8
1 file changed +4 -3
git-gui.sh
+4 -3
@@ -2416,15 +2416,16 @@ $ctxm add separator
2416 $ctxm add command -label {Options...} \
2417 -command do_options
2418 proc popup_diff_menu {ctxm x y X Y} {
2419 - global current_diff_path
2419 + global current_diff_path file_states
2420 set ::cursorX $x
2421 set ::cursorY $y
2422 if {$::ui_index eq $::current_diff_side} {
2423 $ctxm entryconf $::ui_diff_applyhunk \
2424 -state normal \
2425 -label {Unstage Hunk From Commit}
2426 - } elseif {![info exists file_states($current_diff_path)]
2427 - || {_O} eq [lindex $file_states($::current_diff_path) 0]} {
2426 + } elseif {$current_diff_path eq {}
2427 + || ![info exists file_states($current_diff_path)]
2428 + || {_O} eq [lindex $file_states($current_diff_path) 0]} {
2429 $ctxm entryconf $::ui_diff_applyhunk \
2430 -state disabled \
2431 -label {Stage Hunk For Commit}