git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Seymour <jon.seymour@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: spearce@spearce.org
Subject: [PATCH 2/2] Allow git gui to display the diff with the HEAD in the  case of conflicts. [ amended ]
Date: Sun, 28 Mar 2010 13:19:34 +1100	[thread overview]
Message-ID: <2cfc40321003271919kd939540n7354546a95515a8d@mail.gmail.com> (raw)

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

             reply	other threads:[~2010-03-28  2:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-28  2:19 Jon Seymour [this message]
2010-03-28  2:58 ` [PATCH 2/2] Allow git gui to display the diff with the HEAD in the case of conflicts. [ amended ] Jon Seymour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2cfc40321003271919kd939540n7354546a95515a8d@mail.gmail.com \
    --to=jon.seymour@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).