git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] Allow git gui to display the diff with the HEAD in the  case of conflicts. [ amended ]
@ 2010-03-28  2:19 Jon Seymour
  2010-03-28  2:58 ` Jon Seymour
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Seymour @ 2010-03-28  2:19 UTC (permalink / raw)
  To: Git Mailing List; +Cc: spearce

If the configuration variable gui.conflictsdiffwithhead is true,
then the diff displayed for conflicted paths will be the difference
between the working tree and the HEAD.

The rationale for this change is that the previous behaviour did not allow
the user to make an informed decision about whether "Use Local Version"
was safe since non-conflicting changes in the remote branch were already
in the index and thus not visible from git gui.

With this change, the gui displays what the index would contain if
the current working tree copy (including diff markers) was staged
to the index as is. If there are successfully merged hunks from the remote
branch in the index, then these will be visible in diff.

| Amended Use Remote Version -> Use Local Version

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

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 06b2f82..a03c050 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1032,6 +1032,15 @@ gui.commitmsgwidth::
 	Defines how wide the commit message window is in the
 	linkgit:git-gui[1]. "75" is the default.

+gui.conflictsdiffwithhead::
+	If set to "true", then the diff displayed by the gui for unstaged conflicted
+	changes is the diff between the working tree and the HEAD. This mode
+	of operation allows the user to assess whether use of "Use Local
Version" is safe
+	or will discard successfully merged hunks from the remote branch.
+	If set to "false", the diff shown for all unstaged changes is the difference
+	between the working tree and the index.	Default: "false".
+
+
 gui.diffcontext::
 	Specifies how many context lines should be used in calls to diff
 	made by the linkgit:git-gui[1]. The default is "5".
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index e7b1986..7aeb98d 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 && [is_config_true gui.conflictsdiffwithhead]} {
+                 lappend cmd "HEAD"
+            }
+        }
 	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-28  2:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-28  2:19 [PATCH 2/2] Allow git gui to display the diff with the HEAD in the case of conflicts. [ amended ] Jon Seymour
2010-03-28  2:58 ` 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).