Skip to content

Commit ce015c2

Browse files
committed
git-gui: Paper bag fix "Stage Hunk For Commit" in diff context menu
In a13ee29 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 <[email protected]>
1 parent 18a01a0 commit ce015c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

git-gui.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,15 +2416,16 @@ $ctxm add separator
24162416
$ctxm add command -label {Options...} \
24172417
-command do_options
24182418
proc popup_diff_menu {ctxm x y X Y} {
2419-
global current_diff_path
2419+
global current_diff_path file_states
24202420
set ::cursorX $x
24212421
set ::cursorY $y
24222422
if {$::ui_index eq $::current_diff_side} {
24232423
$ctxm entryconf $::ui_diff_applyhunk \
24242424
-state normal \
24252425
-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]} {
24282429
$ctxm entryconf $::ui_diff_applyhunk \
24292430
-state disabled \
24302431
-label {Stage Hunk For Commit}

0 commit comments

Comments
 (0)