{"thread":{"id":"23252","subject":"[PATCH v3 1/2] git-gui: Introduce is_unmerged global variable to encapsulate its derivation.","startedAt":"2010-03-30T15:34:48Z","lastAt":"2010-03-30T15:34:49Z","messageCount":2,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"138184","messageId":"1269963289-480-1-git-send-email-jon.seymour@gmail.com","threadId":"23252","inReplyTo":null,"subject":"[PATCH v3 1/2] git-gui: Introduce is_unmerged global variable to encapsulate its derivation.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-03-30T15:34:48Z","receivedAt":"2010-03-30T15:34:48Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Defined is_unmerged to be [expr {[string first {U} $m] >= 0}]\nand then replaced uses of {[string first {U} $m] >= 0} with {$is_unmerged}.\n\nThis change is made because the subsequent patch will introduce a 3rd use of this expression.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-gui/lib/diff.tcl |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex ec8c11e..e7b1986 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -80,6 +80,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {\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+\tglobal is_unmerged\n \n \tif {$diff_active || ![lock_index read]} return\n \n@@ -98,6 +99,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {\n \tset s $file_states($path)\n \tset m [lindex $s 0]\n \tset is_conflict_diff 0\n+\tset is_unmerged [expr {[string first {U} $m] >= 0}]\n \tset current_diff_path $path\n \tset current_diff_side $w\n \tset current_diff_queue {}\n@@ -105,7 +107,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {\n \n \tset cont_info [list $scroll_pos $callback]\n \n-\tif {[string first {U} $m] >= 0} {\n+\tif {$is_unmerged} {\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 $cont_info\n@@ -258,6 +260,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \tglobal is_3way_diff is_submodule_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 is_unmerged\n \n \tset path $current_diff_path\n \tset w $current_diff_side\n@@ -274,7 +277,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t\tlappend cmd diff-index\n \t\tlappend cmd --cached\n \t} elseif {$w eq $ui_workdir} {\n-\t\tif {[string first {U} $m] >= 0} {\n+\t        if {$is_unmerged} {\n \t\t\tlappend cmd diff\n \t\t} else {\n \t\t\tlappend cmd diff-files\n-- \n1.6.6.1\n"},{"id":"138185","messageId":"1269963289-480-2-git-send-email-jon.seymour@gmail.com","threadId":"23252","inReplyTo":"1269963289-480-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v3 2/2] git-gui: change to display the combined diff in the case of conflicts.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-03-30T15:34:49Z","receivedAt":"2010-03-30T15:34:49Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"The rationale for this change is that the previous behaviour did not allow\nthe user to make an informed decision about the likely consequences\nof \"Use Local Version\", \"Stage to commit\" or \"Use Remote Version\" for conflicted files. The\nreason for this is that in the conflicted case, successfully staged\nremote hunks are effectively invisible to user (via the git-gui interface)\nand hence cannot inform the user's decision making process.\n\nFor example, previously use of \"Use Local Version\" would silently discard\nfrom the index, and the working tree any successfully merged remote hunks.\nSince these hunks had never been displayed to the user, this\nloss would be unnoticed and unexpected.\n\nIn the case of \"Stage to commit\", the successfully merged remote\nhunks would be preserved in the index and the working tree but the fact\nthat there are successfully merged remote hunks would not be not\nvisible until after the \"Stage to commit\" action has been taken.\nIf the user did not check diff _after_ taking the action, the user\nmay have unwittingly commit changes from a remote hunk\nthat she was not aware of.\n\nSimilar coniderations also imply that the probable consequences\nof \"Use Remote Version\" cannot be properly evaluated since the changes\nin the local branch that would be undone by accepting the remote\nbranch's version of the file would are not visible to the user.\n\nWith this change, in the case of conflicted paths only, the git-gui diff window\ndisplays the output of git diff -c. This output allows the user to properly\nevaluate the consequences of the possible resolution actions.\n\nPrevious versions of this patch uses \"diff HEAD\" instead of \"diff\".\nThis version uses \"diff -c\" at the suggestion of Johannes Sixt.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n git-gui/lib/diff.tcl |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex e7b1986..693830f 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -300,7 +300,11 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t}\n \tif {$w eq $ui_index} {\n \t\tlappend cmd [PARENT]\n-\t}\n+\t} else {\n+\t\tif {$is_unmerged} {\n+\t\t\tlappend cmd -c \n+\t\t}\n+        }\n \tif {$add_opts ne {}} {\n \t\teval lappend cmd $add_opts\n \t} else {\n-- \n1.6.6.1\n"}]}