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

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

 



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@xxxxxxxxx> 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@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..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
>
--
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]