summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-08-23 02:39:45 -0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-08-23 02:39:45 -0400
commit9f4119eb7651c7898f385198409be4ca051bc7ef (patch)
treed5e9a8b863105f577bb970928bcddd76a56ffee8 /git-gui.sh
parentgit-gui: Fix "unoptimized loading" to not cause git-gui to crash (diff)
downloadtgif-9f4119eb7651c7898f385198409be4ca051bc7ef.tar.xz
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 <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh23
1 files changed, 11 insertions, 12 deletions
diff --git a/git-gui.sh b/git-gui.sh
index b25b52fd11..559b62be03 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2432,20 +2432,19 @@ proc popup_diff_menu {ctxm x y X Y} {
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 {$current_diff_path eq {}
- || ![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}
+ set s normal
+ set l "Unstage Hunk From Commit"
} else {
- $ctxm entryconf $::ui_diff_applyhunk \
- -state normal \
- -label {Stage Hunk For Commit}
+ if {$current_diff_path eq {}
+ || ![info exists file_states($current_diff_path)]
+ || {_O} eq [lindex $file_states($current_diff_path) 0]} {
+ set s disabled
+ } else {
+ set s normal
+ }
+ set l "Stage Hunk For Commit"
}
+ $ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
tk_popup $ctxm $X $Y
}
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]