Skip to content

Commit

Permalink
git-gui: Make Ctrl-T safe to use for conflicting files.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexander Gavrilov authored and Shawn O. Pearce committed Sep 30, 2008
1 parent d3bcf55 commit 0aea284
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,9 @@ proc toggle_or_diff {w x y} {
if {$col == 0 && $y > 1} {
# Conflicts need special handling
if {[string first {U} $state] >= 0} {
merge_stage_workdir $path $w $lno
# $w must always be $ui_workdir, but...
if {$w ne $ui_workdir} { set lno {} }
merge_stage_workdir $path $lno
return
}
Expand Down
11 changes: 9 additions & 2 deletions lib/index.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,18 @@ proc add_helper {txt paths} {
set after {}
foreach path $paths {
switch -glob -- [lindex $file_states($path) 0] {
_U -
U? {
if {$path eq $current_diff_path} {
unlock_index
merge_stage_workdir $path
return
}
}
_O -
?M -
?D -
?T -
U? {
?T {
lappend pathList $path
if {$path eq $current_diff_path} {
set after {reshow_diff;}
Expand Down
1 change: 1 addition & 0 deletions lib/merge.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The rescan will be automatically started now.
_O {
continue; # and pray it works!
}
_U
U? {
error_popup [mc "You are in the middle of a conflicted merge.
Expand Down
7 changes: 4 additions & 3 deletions lib/mergetool.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ This operation can be undone only by restarting the merge." \
}
}

proc merge_stage_workdir {path w lno} {
proc merge_stage_workdir {path {lno {}}} {
global current_diff_path diff_active
global current_diff_side ui_workdir

if {$diff_active} return

if {$path ne $current_diff_path} {
show_diff $path $w $lno {} [list do_merge_stage_workdir $path]
if {$path ne $current_diff_path || $ui_workdir ne $current_diff_side} {
show_diff $path $ui_workdir $lno {} [list do_merge_stage_workdir $path]
} else {
do_merge_stage_workdir $path
}
Expand Down

0 comments on commit 0aea284

Please sign in to comment.