[PATCH 2/2] Allow git gui to display the diff with the HEAD in the case of conflicts.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 Remote 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.

Signed-off-by: Jon Seymour <jon.seymour@xxxxxxxxx>
---
 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..352b573 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 Remote
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]