@matheusbsbs / matheus-bagliano / commits / 0aea2842d9
Fork 0

git-gui: Make Ctrl-T safe to use for conflicting files.

A previous patch added a check for conflict markers, which is done when the file is about to be staged due to a click on the icon. However, pressing Ctrl-T still immediately stages the file without confirmation. This patch fixes it. The check requires a loaded diff, so staging multiple files at once won't work if they are unmerged. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Alexander Gavrilov committed Sep 30, 2008 at 12:12 UTC 0aea2842d9d556afa4a3e8120e465479ad7368ca
4 files changed +17 -6
git-gui.sh
+3 -1
@@ -2090,7 +2090,9 @@ proc toggle_or_diff {w x y} {
2090 if {$col == 0 && $y > 1} {
2091 # Conflicts need special handling
2092 if {[string first {U} $state] >= 0} {
2093 - merge_stage_workdir $path $w $lno
2093 + # $w must always be $ui_workdir, but...
2094 + if {$w ne $ui_workdir} { set lno {} }
2095 + merge_stage_workdir $path $lno
2096 return
2097 }
2098
lib/index.tcl
+9 -2
@@ -298,11 +298,18 @@ proc add_helper {txt paths} {
298 set after {}
299 foreach path $paths {
300 switch -glob -- [lindex $file_states($path) 0] {
301 + _U -
302 + U? {
303 + if {$path eq $current_diff_path} {
304 + unlock_index
305 + merge_stage_workdir $path
306 + return
307 + }
308 + }
309 _O -
310 ?M -
311 ?D -
304 - ?T -
305 - U? {
312 + ?T {
313 lappend pathList $path
314 if {$path eq $current_diff_path} {
315 set after {reshow_diff;}
lib/merge.tcl
+1
@@ -40,6 +40,7 @@ The rescan will be automatically started now.
40 _O {
41 continue; # and pray it works!
42 }
43 + _U
44 U? {
45 error_popup [mc "You are in the middle of a conflicted merge.
46
lib/mergetool.tcl
+4 -3
@@ -23,13 +23,14 @@ This operation can be undone only by restarting the merge." \
23 }
24 }
25
26 -proc merge_stage_workdir {path w lno} {
26 +proc merge_stage_workdir {path {lno {}}} {
27 global current_diff_path diff_active
28 + global current_diff_side ui_workdir
29
30 if {$diff_active} return
31
31 - if {$path ne $current_diff_path} {
32 - show_diff $path $w $lno {} [list do_merge_stage_workdir $path]
32 + if {$path ne $current_diff_path || $ui_workdir ne $current_diff_side} {
33 + show_diff $path $ui_workdir $lno {} [list do_merge_stage_workdir $path]
34 } else {
35 do_merge_stage_workdir $path
36 }