* [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
* Re: [PATCH 2/2] Allow git gui to display the diff with the HEAD in the case of conflicts. [ amended ]
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
0 siblings, 0 replies; 2+ messages in thread
From: Jon Seymour @ 2010-03-28 2:58 UTC (permalink / raw)
To: Git Mailing List; +Cc: spearce
Sorry, I realise that this patch has some whitespace issues. I'll fix
that in the next iteration.
I would welcome discussion about whether the optionally configured
behaviour should, in fact, be the default behaviour for conflicted
paths.
The reason is that both "Use Local Version" and "Stage to commit" both
make unexpected and irreversible changes to the index in the case that
a conflicted path has a mixture of conflicted hunks and successfully
merged remote hunks. By always displaying a diff between the working
tree and the HEAD the user will know exactly what the consequences of
"Use Local Version" and "Stage to commit" would be. This is not
currently true.
My next iteration of this patch will move the configurable behaviour
into a separate patch so that this patch can be discarded if the
consensus is that the behaviour described above is reasonable default
behaviour.
jon.
On Sun, Mar 28, 2010 at 1:19 PM, Jon Seymour <jon.seymour@gmail.com> wrote:
> 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 [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).