{"thread":{"id":"15720","subject":"[PATCH (GIT-GUI)] git-gui: Make Ctrl-T safe to use for conflicting files.","startedAt":"2008-09-30T08:12:16Z","lastAt":"2008-09-30T08:12:16Z","messageCount":1,"participants":["Alexander Gavrilov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91907","messageId":"200809301212.17080.angavrilov@gmail.com","threadId":"15720","inReplyTo":null,"subject":"[PATCH (GIT-GUI)] git-gui: Make Ctrl-T safe to use for conflicting files.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-09-30T08:12:16Z","receivedAt":"2008-09-30T08:12:16Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"A previous patch added a check for conflict markers, which\nis done when the file is about to be staged due to a click\non the icon. However, pressing Ctrl-T still immediately\nstages the file without confirmation. This patch fixes it.\n\nThe check requires a loaded diff, so staging multiple files\nat once won't work if they are unmerged.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n\n git-gui.sh        |    4 +++-\n lib/index.tcl     |   11 +++++++++--\n lib/merge.tcl     |    1 +\n lib/mergetool.tcl |    7 ++++---\n 4 files changed, 17 insertions(+), 6 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 4085e8f..717817e 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2090,7 +2090,9 @@ proc toggle_or_diff {w x y} {\n \tif {$col == 0 && $y > 1} {\n \t\t# Conflicts need special handling\n \t\tif {[string first {U} $state] >= 0} {\n-\t\t\tmerge_stage_workdir $path $w $lno\n+\t\t\t# $w must always be $ui_workdir, but...\n+\t\t\tif {$w ne $ui_workdir} { set lno {} }\n+\t\t\tmerge_stage_workdir $path $lno\n \t\t\treturn\n \t\t}\n \ndiff --git a/lib/index.tcl b/lib/index.tcl\nindex b045219..d33896a 100644\n--- a/lib/index.tcl\n+++ b/lib/index.tcl\n@@ -298,11 +298,18 @@ proc add_helper {txt paths} {\n \tset after {}\n \tforeach path $paths {\n \t\tswitch -glob -- [lindex $file_states($path) 0] {\n+\t\t_U -\n+\t\tU? {\n+\t\t\tif {$path eq $current_diff_path} {\n+\t\t\t\tunlock_index\n+\t\t\t\tmerge_stage_workdir $path\n+\t\t\t\treturn\n+\t\t\t}\n+\t\t}\n \t\t_O -\n \t\t?M -\n \t\t?D -\n-\t\t?T -\n-\t\tU? {\n+\t\t?T {\n \t\t\tlappend pathList $path\n \t\t\tif {$path eq $current_diff_path} {\n \t\t\t\tset after {reshow_diff;}\ndiff --git a/lib/merge.tcl b/lib/merge.tcl\nindex 5c01875..ac4c7de 100644\n--- a/lib/merge.tcl\n+++ b/lib/merge.tcl\n@@ -40,6 +40,7 @@ The rescan will be automatically started now.\n \t\t_O {\n \t\t\tcontinue; # and pray it works!\n \t\t}\n+\t\t_U\n \t\tU? {\n \t\t\terror_popup [mc \"You are in the middle of a conflicted merge.\n \ndiff --git a/lib/mergetool.tcl b/lib/mergetool.tcl\nindex 6ab5701..1984c64 100644\n--- a/lib/mergetool.tcl\n+++ b/lib/mergetool.tcl\n@@ -23,13 +23,14 @@ This operation can be undone only by restarting the merge.\" \\\n \t}\n }\n \n-proc merge_stage_workdir {path w lno} {\n+proc merge_stage_workdir {path {lno {}}} {\n \tglobal current_diff_path diff_active\n+\tglobal current_diff_side ui_workdir\n \n \tif {$diff_active} return\n \n-\tif {$path ne $current_diff_path} {\n-\t\tshow_diff $path $w $lno {} [list do_merge_stage_workdir $path]\n+\tif {$path ne $current_diff_path || $ui_workdir ne $current_diff_side} {\n+\t\tshow_diff $path $ui_workdir $lno {} [list do_merge_stage_workdir $path]\n \t} else {\n \t\tdo_merge_stage_workdir $path\n \t}\n-- \n1.6.0.20.g6148bc\n"}]}