git-gui: Don't allow staging files with conflicts.
authorAlexander Gavrilov <angavrilov@gmail.com>
Sat, 30 Aug 2008 20:54:19 +0000 (00:54 +0400)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 5 Sep 2008 04:28:55 +0000 (21:28 -0700)
Prevent staging files with conflict markers by clicking
on the icon in the 'Unstaged Changes' list. Instead, pretend
that the user clicked the name, and show the diff.

Originally it made some sense to allow staging conflicting
files, because git-gui did not provide any tools to resolve
them from within the GUI. But now that we have added mergetool
capabilities, it is more likely to cause accidental and
non-undoable errors.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui.sh

index 677a27150c4e5c6c45b95034606363d02152cf87..061fac768d808586554cabcdffee95fd0d1150c2 100755 (executable)
@@ -1840,6 +1840,14 @@ proc toggle_or_diff {w x y} {
        $ui_index tag remove in_sel 0.0 end
        $ui_workdir tag remove in_sel 0.0 end
 
+       # Do not stage files with conflicts
+       if {[info exists file_states($path)]} {
+               set state [lindex $file_states($path) 0]
+               if {[string index $state 0] eq {U}} {
+                       set col 1
+               }
+       }
+
        if {$col == 0 && $y > 1} {
                set i [expr {$lno-1}]
                set ll [expr {[llength $file_lists($w)]-1}]