Skip to content

Commit 617ceee

Browse files
angavrilovspearce
authored andcommitted
git-gui: Don't allow staging files with conflicts.
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>
1 parent 7e30682 commit 617ceee

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

git-gui.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,14 @@ proc toggle_or_diff {w x y} {
18401840
$ui_index tag remove in_sel 0.0 end
18411841
$ui_workdir tag remove in_sel 0.0 end
18421842
1843+
# Do not stage files with conflicts
1844+
if {[info exists file_states($path)]} {
1845+
set state [lindex $file_states($path) 0]
1846+
if {[string index $state 0] eq {U}} {
1847+
set col 1
1848+
}
1849+
}
1850+
18431851
if {$col == 0 && $y > 1} {
18441852
set i [expr {$lno-1}]
18451853
set ll [expr {[llength $file_lists($w)]-1}]

0 commit comments

Comments
 (0)