git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] git-gui: Introduce is_unmerged global variable to encapsulate its derivation.
@ 2010-03-30 15:34 Jon Seymour
  2010-03-30 15:34 ` [PATCH v3 2/2] git-gui: change to display the combined diff in the case of conflicts Jon Seymour
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Seymour @ 2010-03-30 15:34 UTC (permalink / raw)
  To: jon.seymour; +Cc: git, spearce, j.sixt

Defined is_unmerged to be [expr {[string first {U} $m] >= 0}]
and then replaced uses of {[string first {U} $m] >= 0} with {$is_unmerged}.

This change is made because the subsequent patch will introduce a 3rd use of this expression.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
 git-gui/lib/diff.tcl |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index ec8c11e..e7b1986 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -80,6 +80,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {
 	global ui_diff ui_index ui_workdir
 	global current_diff_path current_diff_side current_diff_header
 	global current_diff_queue
+	global is_unmerged
 
 	if {$diff_active || ![lock_index read]} return
 
@@ -98,6 +99,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {
 	set s $file_states($path)
 	set m [lindex $s 0]
 	set is_conflict_diff 0
+	set is_unmerged [expr {[string first {U} $m] >= 0}]
 	set current_diff_path $path
 	set current_diff_side $w
 	set current_diff_queue {}
@@ -105,7 +107,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {
 
 	set cont_info [list $scroll_pos $callback]
 
-	if {[string first {U} $m] >= 0} {
+	if {$is_unmerged} {
 		merge_load_stages $path [list show_unmerged_diff $cont_info]
 	} elseif {$m eq {_O}} {
 		show_other_diff $path $w $m $cont_info
@@ -258,6 +260,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 	global is_3way_diff is_submodule_diff diff_active repo_config
 	global ui_diff ui_index ui_workdir
 	global current_diff_path current_diff_side current_diff_header
+	global is_unmerged
 
 	set path $current_diff_path
 	set w $current_diff_side
@@ -274,7 +277,7 @@ proc start_show_diff {cont_info {add_opts {}}} {
 		lappend cmd diff-index
 		lappend cmd --cached
 	} elseif {$w eq $ui_workdir} {
-		if {[string first {U} $m] >= 0} {
+	        if {$is_unmerged} {
 			lappend cmd diff
 		} else {
 			lappend cmd diff-files
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v3 2/2] git-gui: change to display the combined diff in the case of conflicts.
  2010-03-30 15:34 [PATCH v3 1/2] git-gui: Introduce is_unmerged global variable to encapsulate its derivation Jon Seymour
@ 2010-03-30 15:34 ` Jon Seymour
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Seymour @ 2010-03-30 15:34 UTC (permalink / raw)
  To: jon.seymour; +Cc: git, spearce, j.sixt

The rationale for this change is that the previous behaviour did not allow
the user to make an informed decision about the likely consequences
of "Use Local Version", "Stage to commit" or "Use Remote Version" for conflicted files. The
reason for this is that in the conflicted case, successfully staged
remote hunks are effectively invisible to user (via the git-gui interface)
and hence cannot inform the user's decision making process.

For example, previously use of "Use Local Version" would silently discard
from the index, and the working tree any successfully merged remote hunks.
Since these hunks had never been displayed to the user, this
loss would be unnoticed and unexpected.

In the case of "Stage to commit", the successfully merged remote
hunks would be preserved in the index and the working tree but the fact
that there are successfully merged remote hunks would not be not
visible until after the "Stage to commit" action has been taken.
If the user did not check diff _after_ taking the action, the user
may have unwittingly commit changes from a remote hunk
that she was not aware of.

Similar coniderations also imply that the probable consequences
of "Use Remote Version" cannot be properly evaluated since the changes
in the local branch that would be undone by accepting the remote
branch's version of the file would are not visible to the user.

With this change, in the case of conflicted paths only, the git-gui diff window
displays the output of git diff -c. This output allows the user to properly
evaluate the consequences of the possible resolution actions.

Previous versions of this patch uses "diff HEAD" instead of "diff".
This version uses "diff -c" at the suggestion of Johannes Sixt.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
 git-gui/lib/diff.tcl |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index e7b1986..693830f 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -300,7 +300,11 @@ proc start_show_diff {cont_info {add_opts {}}} {
 	}
 	if {$w eq $ui_index} {
 		lappend cmd [PARENT]
-	}
+	} else {
+		if {$is_unmerged} {
+			lappend cmd -c 
+		}
+        }
 	if {$add_opts ne {}} {
 		eval lappend cmd $add_opts
 	} else {
-- 
1.6.6.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-30 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30 15:34 [PATCH v3 1/2] git-gui: Introduce is_unmerged global variable to encapsulate its derivation Jon Seymour
2010-03-30 15:34 ` [PATCH v3 2/2] git-gui: change to display the combined diff in the case of conflicts Jon Seymour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).