Skip to content

Commit 9f4119e

Browse files
committed
git-gui: Refactor diff pane popup support for future improvements
The current popup_diff_menu procedure is somewhat messy as it has a few duplications of the same logic in each of the different legs of the routine. We can simplify these by setting a few state variables in the different legs. No functional change, just a cleanup to make it easier to implement future functional changes within this block. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 875b7c9 commit 9f4119e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

git-gui.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,20 +2432,19 @@ proc popup_diff_menu {ctxm x y X Y} {
24322432
set ::cursorX $x
24332433
set ::cursorY $y
24342434
if {$::ui_index eq $::current_diff_side} {
2435-
$ctxm entryconf $::ui_diff_applyhunk \
2436-
-state normal \
2437-
-label {Unstage Hunk From Commit}
2438-
} elseif {$current_diff_path eq {}
2439-
|| ![info exists file_states($current_diff_path)]
2440-
|| {_O} eq [lindex $file_states($current_diff_path) 0]} {
2441-
$ctxm entryconf $::ui_diff_applyhunk \
2442-
-state disabled \
2443-
-label {Stage Hunk For Commit}
2435+
set s normal
2436+
set l "Unstage Hunk From Commit"
24442437
} else {
2445-
$ctxm entryconf $::ui_diff_applyhunk \
2446-
-state normal \
2447-
-label {Stage Hunk For Commit}
2438+
if {$current_diff_path eq {}
2439+
|| ![info exists file_states($current_diff_path)]
2440+
|| {_O} eq [lindex $file_states($current_diff_path) 0]} {
2441+
set s disabled
2442+
} else {
2443+
set s normal
2444+
}
2445+
set l "Stage Hunk For Commit"
24482446
}
2447+
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
24492448
tk_popup $ctxm $X $Y
24502449
}
24512450
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]

0 commit comments

Comments
 (0)