{"thread":{"id":"15603","subject":"[PATCH (GIT-GUI)] git-gui: Reenable staging unmerged files by clicking the icon.","startedAt":"2008-09-20T08:19:18Z","lastAt":"2008-09-24T19:53:01Z","messageCount":4,"participants":["Alexander Gavrilov","Johannes Sixt","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"91167","messageId":"200809201219.18630.angavrilov@gmail.com","threadId":"15603","inReplyTo":null,"subject":"[PATCH (GIT-GUI)] git-gui: Reenable staging unmerged files by clicking the icon.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-09-20T08:19:18Z","receivedAt":"2008-09-20T08:19:18Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"This restores functionality of the file icon for unmerged files.\nSafety is enforced by loading the diff and checking for lines\nthat look like conflict markers. If such lines are found, or\nthe conflict involves deletion and/or symlinks, a confirmation\ndialog is presented. Otherwise, the icon immediately stages the\nworking copy version of the file.\n\nIncludes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca\n(Restore ability to Stage Working Copy for conflicts)\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n git-gui.sh        |   18 ++++++++----------\n lib/diff.tcl      |   52 +++++++++++++++++++++++++++++++++++-----------------\n lib/mergetool.tcl |   33 +++++++++++++++++++++++++++------\n 3 files changed, 70 insertions(+), 33 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 3bbb4f1..9e5b122 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -1059,6 +1059,7 @@ set current_branch {}\n set is_detached 0\n set current_diff_path {}\n set is_3way_diff 0\n+set is_conflict_diff 0\n set selected_commit_type new\n \n set nullid \"0000000000000000000000000000000000000000\"\n@@ -2013,19 +2014,21 @@ proc toggle_or_diff {w x y} {\n \t$ui_index tag remove in_sel 0.0 end\n \t$ui_workdir tag remove in_sel 0.0 end\n \n-\t# Do not stage files with conflicts\n+\t# Determine the state of the file\n \tif {[info exists file_states($path)]} {\n \t\tset state [lindex $file_states($path) 0]\n \t} else {\n \t\tset state {__}\n \t}\n \n-\tif {[string first {U} $state] >= 0} {\n-\t\tset col 1\n-\t}\n-\n \t# Restage the file, or simply show the diff\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\treturn\n+\t\t}\n+\n \t\tif {[string index $state 1] eq {O}} {\n \t\t\tset mmask {}\n \t\t} else {\n@@ -2984,11 +2987,6 @@ $ctxmmg add command \\\n \t-command {merge_resolve_one 1}\n lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]\n $ctxmmg add separator\n-$ctxmmg add command \\\n-\t-label [mc \"Stage Working Copy\"] \\\n-\t-command {merge_resolve_one 0}\n-lappend diff_actions [list $ctxmmg entryconf [$ctxmmg index last] -state]\n-$ctxmmg add separator\n create_common_diff_popup $ctxmmg\n \n proc popup_diff_menu {ctxm ctxmmg x y X Y} {\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex b616296..abe502d 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -69,9 +69,9 @@ A rescan will be automatically started to find other files which may have the sa\n \trescan ui_ready 0\n }\n \n-proc show_diff {path w {lno {}} {scroll_pos {}}} {\n+proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {\n \tglobal file_states file_lists\n-\tglobal is_3way_diff diff_active repo_config\n+\tglobal is_3way_diff is_conflict_diff diff_active repo_config\n \tglobal ui_diff ui_index ui_workdir\n \tglobal current_diff_path current_diff_side current_diff_header\n \tglobal current_diff_queue\n@@ -92,36 +92,42 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {\n \n \tset s $file_states($path)\n \tset m [lindex $s 0]\n+\tset is_conflict_diff 0\n \tset current_diff_path $path\n \tset current_diff_side $w\n \tset current_diff_queue {}\n \tui_status [mc \"Loading diff of %s...\" [escape_path $path]]\n \n+\tset cont_info [list $scroll_pos $callback]\n+\n \tif {[string first {U} $m] >= 0} {\n-\t\tmerge_load_stages $path [list show_unmerged_diff $scroll_pos]\n+\t\tmerge_load_stages $path [list show_unmerged_diff $cont_info]\n \t} elseif {$m eq {_O}} {\n-\t\tshow_other_diff $path $w $m $scroll_pos\n+\t\tshow_other_diff $path $w $m $cont_info\n \t} else {\n-\t\tstart_show_diff $scroll_pos\n+\t\tstart_show_diff $cont_info\n \t}\n }\n \n-proc show_unmerged_diff {scroll_pos} {\n+proc show_unmerged_diff {cont_info} {\n \tglobal current_diff_path current_diff_side\n-\tglobal merge_stages ui_diff\n+\tglobal merge_stages ui_diff is_conflict_diff\n \tglobal current_diff_queue\n \n \tif {$merge_stages(2) eq {}} {\n+\t\tset is_conflict_diff 1\n \t\tlappend current_diff_queue \\\n \t\t\t[list \"LOCAL: deleted\\nREMOTE:\\n\" d======= \\\n \t\t\t    [list \":1:$current_diff_path\" \":3:$current_diff_path\"]]\n \t} elseif {$merge_stages(3) eq {}} {\n+\t\tset is_conflict_diff 1\n \t\tlappend current_diff_queue \\\n \t\t\t[list \"REMOTE: deleted\\nLOCAL:\\n\" d======= \\\n \t\t\t    [list \":1:$current_diff_path\" \":2:$current_diff_path\"]]\n \t} elseif {[lindex $merge_stages(1) 0] eq {120000}\n \t\t|| [lindex $merge_stages(2) 0] eq {120000}\n \t\t|| [lindex $merge_stages(3) 0] eq {120000}} {\n+\t\tset is_conflict_diff 1\n \t\tlappend current_diff_queue \\\n \t\t\t[list \"LOCAL:\\n\" d======= \\\n \t\t\t    [list \":1:$current_diff_path\" \":2:$current_diff_path\"]]\n@@ -129,14 +135,14 @@ proc show_unmerged_diff {scroll_pos} {\n \t\t\t[list \"REMOTE:\\n\" d======= \\\n \t\t\t    [list \":1:$current_diff_path\" \":3:$current_diff_path\"]]\n \t} else {\n-\t\tstart_show_diff $scroll_pos\n+\t\tstart_show_diff $cont_info\n \t\treturn\n \t}\n \n-\tadvance_diff_queue $scroll_pos\n+\tadvance_diff_queue $cont_info\n }\n \n-proc advance_diff_queue {scroll_pos} {\n+proc advance_diff_queue {cont_info} {\n \tglobal current_diff_queue ui_diff\n \n \tset item [lindex $current_diff_queue 0]\n@@ -146,10 +152,10 @@ proc advance_diff_queue {scroll_pos} {\n \t$ui_diff insert end [lindex $item 0] [lindex $item 1]\n \t$ui_diff conf -state disabled\n \n-\tstart_show_diff $scroll_pos [lindex $item 2]\n+\tstart_show_diff $cont_info [lindex $item 2]\n }\n \n-proc show_other_diff {path w m scroll_pos} {\n+proc show_other_diff {path w m cont_info} {\n \tglobal file_states file_lists\n \tglobal is_3way_diff diff_active repo_config\n \tglobal ui_diff ui_index ui_workdir\n@@ -228,16 +234,21 @@ proc show_other_diff {path w m scroll_pos} {\n \t\t$ui_diff conf -state disabled\n \t\tset diff_active 0\n \t\tunlock_index\n+\t\tset scroll_pos [lindex $cont_info 0]\n \t\tif {$scroll_pos ne {}} {\n \t\t\tupdate\n \t\t\t$ui_diff yview moveto $scroll_pos\n \t\t}\n \t\tui_ready\n+\t\tset callback [lindex $cont_info 1]\n+\t\tif {$callback ne {}} {\n+\t\t\teval $callback\n+\t\t}\n \t\treturn\n \t}\n }\n \n-proc start_show_diff {scroll_pos {add_opts {}}} {\n+proc start_show_diff {cont_info {add_opts {}}} {\n \tglobal file_states file_lists\n \tglobal is_3way_diff diff_active repo_config\n \tglobal ui_diff ui_index ui_workdir\n@@ -292,12 +303,12 @@ proc start_show_diff {scroll_pos {add_opts {}}} {\n \t\t-blocking 0 \\\n \t\t-encoding [get_path_encoding $path] \\\n \t\t-translation lf\n-\tfileevent $fd readable [list read_diff $fd $scroll_pos]\n+\tfileevent $fd readable [list read_diff $fd $cont_info]\n }\n \n-proc read_diff {fd scroll_pos} {\n+proc read_diff {fd cont_info} {\n \tglobal ui_diff diff_active\n-\tglobal is_3way_diff current_diff_header\n+\tglobal is_3way_diff is_conflict_diff current_diff_header\n \tglobal current_diff_queue\n \n \t$ui_diff conf -state normal\n@@ -345,6 +356,7 @@ proc read_diff {fd scroll_pos} {\n \t\t\t{--} {set tags d_--}\n \t\t\t{++} {\n \t\t\t\tif {[regexp {^\\+\\+([<>]{7} |={7})} $line _g op]} {\n+\t\t\t\t\tset is_conflict_diff 1\n \t\t\t\t\tset line [string replace $line 0 1 {  }]\n \t\t\t\t\tset tags d$op\n \t\t\t\t} else {\n@@ -364,6 +376,7 @@ proc read_diff {fd scroll_pos} {\n \t\t\t{-} {set tags d_-}\n \t\t\t{+} {\n \t\t\t\tif {[regexp {^\\+([<>]{7} |={7})} $line _g op]} {\n+\t\t\t\t\tset is_conflict_diff 1\n \t\t\t\t\tset line [string replace $line 0 0 { }]\n \t\t\t\t\tset tags d$op\n \t\t\t\t} else {\n@@ -388,12 +401,13 @@ proc read_diff {fd scroll_pos} {\n \t\tclose $fd\n \n \t\tif {$current_diff_queue ne {}} {\n-\t\t\tadvance_diff_queue $scroll_pos\n+\t\t\tadvance_diff_queue $cont_info\n \t\t\treturn\n \t\t}\n \n \t\tset diff_active 0\n \t\tunlock_index\n+\t\tset scroll_pos [lindex $cont_info 0]\n \t\tif {$scroll_pos ne {}} {\n \t\t\tupdate\n \t\t\t$ui_diff yview moveto $scroll_pos\n@@ -403,6 +417,10 @@ proc read_diff {fd scroll_pos} {\n \t\tif {[$ui_diff index end] eq {2.0}} {\n \t\t\thandle_empty_diff\n \t\t}\n+\t\tset callback [lindex $cont_info 1]\n+\t\tif {$callback ne {}} {\n+\t\t\teval $callback\n+\t\t}\n \t}\n }\n \ndiff --git a/lib/mergetool.tcl b/lib/mergetool.tcl\nindex dd2315b..9693e47 100644\n--- a/lib/mergetool.tcl\n+++ b/lib/mergetool.tcl\n@@ -5,12 +5,6 @@ proc merge_resolve_one {stage} {\n \tglobal current_diff_path\n \n \tswitch -- $stage {\n-\t\t0 {\t# Stage without confirmation, to minimize\n-\t\t\t# disruption of the rerere workflow\n-\t\t\tmerge_add_resolution $current_diff_path\n-\t\t\treturn\n-\t\t}\n-\n \t\t1 { set target [mc \"the base version\"] }\n \t\t2 { set target [mc \"this branch\"] }\n \t\t3 { set target [mc \"the other branch\"] }\n@@ -29,6 +23,33 @@ This operation can be undone only by restarting the merge.\" \\\n \t}\n }\n \n+proc merge_stage_workdir {path w lno} {\n+\tglobal current_diff_path diff_active\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+\t} else {\n+\t\tdo_merge_stage_workdir $path\n+\t}\n+}\n+\n+proc do_merge_stage_workdir {path} {\n+\tglobal current_diff_path is_conflict_diff\n+\n+\tif {$path ne $current_diff_path} return;\n+\n+\tif {$is_conflict_diff} {\n+\t\tif {[ask_popup [mc \"File %s seems to have unresolved conflicts, still stage?\" \\\n+\t\t\t\t[short_path $path]]] ne {yes}} {\n+\t\t\treturn\n+\t\t}\n+\t}\n+\n+\tmerge_add_resolution $path\n+}\n+\n proc merge_add_resolution {path} {\n \tglobal current_diff_path ui_workdir\n \n-- \n1.6.0.20.g6148bc\n"},{"id":"91282","messageId":"48D749B7.9030305@viscovery.net","threadId":"15603","inReplyTo":"200809201219.18630.angavrilov@gmail.com","subject":"Re: [PATCH (GIT-GUI)] git-gui: Reenable staging unmerged files by clicking the icon.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-22T07:31:03Z","receivedAt":"2008-09-22T07:31:03Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Alexander Gavrilov schrieb:\n> This restores functionality of the file icon for unmerged files.\n> Safety is enforced by loading the diff and checking for lines\n> that look like conflict markers. If such lines are found, or\n> the conflict involves deletion and/or symlinks, a confirmation\n> dialog is presented. Otherwise, the icon immediately stages the\n> working copy version of the file.\n> \n> Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca\n> (Restore ability to Stage Working Copy for conflicts)\n\nThanks, works fine after a brief test:\n\nTested-by: Johannes Sixt <johannes.sixt@telecom.at>\n\n-- Hannes\n"},{"id":"91508","messageId":"20080924182508.GC3669@spearce.org","threadId":"15603","inReplyTo":"200809201219.18630.angavrilov@gmail.com","subject":"Re: [PATCH (GIT-GUI)] git-gui: Reenable staging unmerged files by clicking the icon.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-24T18:25:08Z","receivedAt":"2008-09-24T18:25:08Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alexander Gavrilov <angavrilov@gmail.com> wrote:\n> This restores functionality of the file icon for unmerged files.\n> Safety is enforced by loading the diff and checking for lines\n> that look like conflict markers. If such lines are found, or\n> the conflict involves deletion and/or symlinks, a confirmation\n> dialog is presented. Otherwise, the icon immediately stages the\n> working copy version of the file.\n> \n> Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca\n> (Restore ability to Stage Working Copy for conflicts)\n> \n> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n> ---\n>  git-gui.sh        |   18 ++++++++----------\n>  lib/diff.tcl      |   52 +++++++++++++++++++++++++++++++++++-----------------\n>  lib/mergetool.tcl |   33 +++++++++++++++++++++++++++------\n>  3 files changed, 70 insertions(+), 33 deletions(-)\n\nCan I get a resend of this patch?\n\nI don't seem to have the base objects it applies to, and it doesn't\napply clean to any branch I can find... :-|\n\n \n-- \nShawn.\n"},{"id":"91515","messageId":"20080924195301.GA29793@spearce.org","threadId":"15603","inReplyTo":"20080924182508.GC3669@spearce.org","subject":"Re: [PATCH (GIT-GUI)] git-gui: Reenable staging unmerged files by clicking the icon.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-24T19:53:01Z","receivedAt":"2008-09-24T19:53:01Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> wrote:\n> Alexander Gavrilov <angavrilov@gmail.com> wrote:\n> > This restores functionality of the file icon for unmerged files.\n> > Safety is enforced by loading the diff and checking for lines\n> > that look like conflict markers. If such lines are found, or\n> > the conflict involves deletion and/or symlinks, a confirmation\n> > dialog is presented. Otherwise, the icon immediately stages the\n> > working copy version of the file.\n> > \n> > Includes a revert of 2fe5b2ee42897a3acc78e5ddaace3775eb2713ca\n> > (Restore ability to Stage Working Copy for conflicts)\n> \n> Can I get a resend of this patch?\n\nNever mind.  Its applied now.  I broke down after lunch and found\nthe one hunk that was an issue, and trivially hand merged it.\n \n-- \nShawn.\n"}]}