summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-09-02 19:38:04 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-09-04 03:03:52 (GMT)
commit047d94d505c9837a60c28e121de65471dadce74b (patch)
treed6014afc11bc18746fb5207edb4744fca5084cd9 /git-gui.sh
parent881d8f24cab5bf4e0fa71b17a3ab82e27b2e8ed7 (diff)
downloadgit-047d94d505c9837a60c28e121de65471dadce74b.zip
git-047d94d505c9837a60c28e121de65471dadce74b.tar.gz
git-047d94d505c9837a60c28e121de65471dadce74b.tar.bz2
git-gui: Properly set the state of "Stage/Unstage Hunk" action
Today I found yet another way for the "Stage Hunk" and "Unstage Hunk" context menu actions to leave the wrong state enabled in the UI. The problem this time was that I connected the state determination to the value of $::current_diff_side (the side the diff is from). When the user was last looking at a diff from the index side and unstages everything the diff panel goes empty, but the action stayed enabled as we always assumed unstaging was a valid action. This change moves the logic for determining when the action is enabled away from the individual side selection, as they really are two unrelated concepts. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh15
1 files changed, 6 insertions, 9 deletions
diff --git a/git-gui.sh b/git-gui.sh
index e495046..44977aa 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2441,20 +2441,17 @@ proc popup_diff_menu {ctxm x y X Y} {
set ::cursorX $x
set ::cursorY $y
if {$::ui_index eq $::current_diff_side} {
- set s normal
set l "Unstage Hunk From Commit"
} else {
- 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"
}
- if {$::is_3way_diff} {
+ if {$::is_3way_diff
+ || $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
}
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
tk_popup $ctxm $X $Y