git-gui: Add or unstage based on the specific icon used.
Rather than relying on the file state and just inverting it, we should look at which file icon the user clicked on. If they clicked on the one in the "Changes To Be Committed" list then they want to unstage the file. If they clicked on the icon in the "Changed But Not Updated" list then they want to add the file to the commit. This should be much more reliable about capturing the user's intent then looking at the file state. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 20, 2007 at 23:10 UTC
de5f6d5d178a1c8113aaca34c8f6b3842732a741
1 file changed
+2
-8
git-gui.sh
+2
-8
@@ -2867,23 +2867,17 @@ proc toggle_or_diff {w x y} {
2867
} else {
2868
set after {}
2869
}
2870
- switch -glob -- [lindex $file_states($path) 0] {
2871
- A_ -
2872
- M_ -
2873
- D_ -
2874
- DO {
2870
+ if {$w eq $ui_index} {
2871
update_indexinfo \
2872
"Unstaging [short_path $path] from commit" \
2873
[list $path] \
2874
[concat $after {set ui_status_value {Ready.}}]
2879
- }
2880
- ?? {
2875
+ } elseif {$w eq $ui_workdir} {
2876
update_index \
2877
"Adding [short_path $path]" \
2878
[list $path] \
2879
[concat $after {set ui_status_value {Ready.}}]
2880
}
2886
- }
2881
} else {
2882
show_diff $path $w $lno
2883
}