git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Conflict markers in mergetool $LOCAL ?
@ 2010-08-17  4:34 Seth House
  2010-08-17  9:30 ` David Aguilar
  0 siblings, 1 reply; 8+ messages in thread
From: Seth House @ 2010-08-17  4:34 UTC (permalink / raw)
  To: git

Hello. I'm a recent convert from Mercurial; I'm enjoying the transition and am
feeling pretty comfortable with most of Git. However, I haven't used mergetool
much yet because it puts conflict markers in the "ours" pane -- but (even after
a chat in #git on IRC) I'm not sure if that is intended behavior or if my setup
is broken. I would appreciate some guidance.

For small conflicts, I like the conflict markers and simply editing the
conflicted file with Vim. For files with lots of conflicts I would like to use
vimdiff but I wouldn't expect the conflict markers to appear there -- it's
redundant information in a 3-way merge.

Is there a better Git Way (TM) that I'm missing? Is my Git setup borked
somehow?

I have the following in my ~/.gitconfig and a stock Git installation on Arch
Linux.

[merge]
    tool = vimdiff

[mergetool "vimdiff"]
    cmd = vimdiff
    trustExitCode = true

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17  4:34 Conflict markers in mergetool $LOCAL ? Seth House
@ 2010-08-17  9:30 ` David Aguilar
  2010-08-17  9:32   ` David Aguilar
  2010-08-17 17:08   ` Seth House
  0 siblings, 2 replies; 8+ messages in thread
From: David Aguilar @ 2010-08-17  9:30 UTC (permalink / raw)
  To: Seth House; +Cc: git

On Tue, Aug 17, 2010 at 04:34:20AM +0000, Seth House wrote:
> [...]
> For small conflicts, I like the conflict markers and simply editing the
> conflicted file with Vim. For files with lots of conflicts I would like to use
> vimdiff but I wouldn't expect the conflict markers to appear there -- it's
> redundant information in a 3-way merge.
> 
> Is there a better Git Way (TM) that I'm missing? Is my Git setup borked
> somehow?
> 
> I have the following in my ~/.gitconfig and a stock Git installation on Arch
> Linux.
> 
> [merge]
>     tool = vimdiff


What happens if you remove this section?:

> [mergetool "vimdiff"]
>     cmd = vimdiff
>     trustExitCode = true

mergetool has built-in support for vimdiff.
You shouldn't need to define mergetool.vimdiff.cmd.

Does that change anything?

-- 

	David

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17  9:30 ` David Aguilar
@ 2010-08-17  9:32   ` David Aguilar
  2010-08-17 17:08   ` Seth House
  1 sibling, 0 replies; 8+ messages in thread
From: David Aguilar @ 2010-08-17  9:32 UTC (permalink / raw)
  To: Seth House; +Cc: git

On Tue, Aug 17, 2010 at 02:30:23AM -0700, David Aguilar wrote:
> On Tue, Aug 17, 2010 at 04:34:20AM +0000, Seth House wrote:
> > [...]
> > For small conflicts, I like the conflict markers and simply editing the
> > conflicted file with Vim. For files with lots of conflicts I would like to use
> > vimdiff but I wouldn't expect the conflict markers to appear there -- it's
> > redundant information in a 3-way merge.
> > 
> > Is there a better Git Way (TM) that I'm missing? Is my Git setup borked
> > somehow?
> > 
> > I have the following in my ~/.gitconfig and a stock Git installation on Arch
> > Linux.
> > 
> > [merge]
> >     tool = vimdiff
> 
> 
> What happens if you remove this section?:
> 
> > [mergetool "vimdiff"]
> >     cmd = vimdiff
> >     trustExitCode = true
> 
> mergetool has built-in support for vimdiff.
> You shouldn't need to define mergetool.vimdiff.cmd.

Typo,                          ^^^^^^^^^^^^^^^^^^^^^
Should say:                    mergetool.cmd.vimdiff

-- 

	David

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17  9:30 ` David Aguilar
  2010-08-17  9:32   ` David Aguilar
@ 2010-08-17 17:08   ` Seth House
  2010-08-17 18:00     ` Jacob Helwig
  1 sibling, 1 reply; 8+ messages in thread
From: Seth House @ 2010-08-17 17:08 UTC (permalink / raw)
  To: git

David Aguilar <davvid <at> gmail.com> writes:
> What happens if you remove this section?:

Same result. The conflict markers are still there:

http://i.imgur.com/d1vp1.png

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17 17:08   ` Seth House
@ 2010-08-17 18:00     ` Jacob Helwig
  2010-08-17 21:04       ` Seth House
  0 siblings, 1 reply; 8+ messages in thread
From: Jacob Helwig @ 2010-08-17 18:00 UTC (permalink / raw)
  To: Seth House, git

That actually looks exactly like it should.  The order of the windows that vimdiff uses is (IIRC): ours, on-disk file, theirs.

"Seth House" <seth@eseth.com> wrote:

>David Aguilar <davvid <at> gmail.com> writes:
>> What happens if you remove this section?:
>
>Same result. The conflict markers are still there:
>
>http://i.imgur.com/d1vp1.png
>
>--
>To unsubscribe from this list: send the line "unsubscribe git" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17 18:00     ` Jacob Helwig
@ 2010-08-17 21:04       ` Seth House
  2010-08-17 21:24         ` Charles Bailey
  0 siblings, 1 reply; 8+ messages in thread
From: Seth House @ 2010-08-17 21:04 UTC (permalink / raw)
  To: git

Jacob Helwig <jacob.helwig <at> gmail.com> writes:
> That actually looks exactly like it should.  The order of the windows
> that vimdiff uses is (IIRC): ours, on-disk file, theirs.

Hm, you’re right. I just found the git-mergetool--lib script on my
system and it opens vimdiff with $LOCAL $MERGED $REMOTE. Thank you, that
opened my eyes enough to clarify my question:

The conflict markers don't seem very useful in the context of a merge
tool. I would prefer to see two windows in vimdiff with each side of the
conflict, respectively. Something like:

vimdiff $MERGED-left-hand-conflicts $MERGED-right-hand-conflicts

Is that possible with Git -- or does anyone know of external tools to
help with such a workflow?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17 21:04       ` Seth House
@ 2010-08-17 21:24         ` Charles Bailey
  2010-08-18  3:22           ` Seth House
  0 siblings, 1 reply; 8+ messages in thread
From: Charles Bailey @ 2010-08-17 21:24 UTC (permalink / raw)
  To: Seth House; +Cc: git

On 17/08/2010 22:04, Seth House wrote:
> Jacob Helwig<jacob.helwig<at>  gmail.com>  writes:
>> That actually looks exactly like it should.  The order of the windows
>> that vimdiff uses is (IIRC): ours, on-disk file, theirs.
>
> Hm, you’re right. I just found the git-mergetool--lib script on my
> system and it opens vimdiff with $LOCAL $MERGED $REMOTE. Thank you, that
> opened my eyes enough to clarify my question:
>
> The conflict markers don't seem very useful in the context of a merge
> tool. I would prefer to see two windows in vimdiff with each side of the
> conflict, respectively. Something like:
>
> vimdiff $MERGED-left-hand-conflicts $MERGED-right-hand-conflicts
>
> Is that possible with Git -- or does anyone know of external tools to
> help with such a workflow?

I think that your problem is mainly with vimdiff, not with mergetool. Or 
perhaps the way they interact. Although I'm a heavy vim user I don't 
really get on with vimdiff as a merge tool. Most 3-way merge tools use 
BASE, LOCAL and REMOTE to allow a good semi-automatic conflict 
resolution to be performed. vimdiff is used by mergetool as a two-way 
diff tool with an extra edit pane; it's not quite the same thing.

The conflict markers have been but into the target file by merge before 
mergetool even starts and mergetool considers the target file to be an 
output only.

I personally have used and would recommend kdiff3 and the Perforce 
visual merge tool with git. Can I suggest you try a different mergetool 
to see if you works better for you?

Charles.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Conflict markers in mergetool $LOCAL ?
  2010-08-17 21:24         ` Charles Bailey
@ 2010-08-18  3:22           ` Seth House
  0 siblings, 0 replies; 8+ messages in thread
From: Seth House @ 2010-08-18  3:22 UTC (permalink / raw)
  To: git

Charles Bailey <charles <at> hashpling.org> writes:
> Most 3-way merge tools use BASE, LOCAL and REMOTE

That is how Mercurial invokes vimdiff, except it also uses a wrapper
shell script in order to tell vimdiff where to save the final edit.

That said, you're right that vimdiff doesn't do the "good semi-automatic
conflict resolution" that you spoke of.

> I personally have used and would recommend kdiff3

I spent some time playing with kdiff3 today. Thanks for the
recommendation. I now understand why a merge tool that has native
support for comparing all four file versions ($BASE, $LOCAL, $REMOTE,
and $MERGED) is vastly more powerful than tools that don't (vimdiff,
Meld) -- and I wish that bit of information would make it into more
diff-tool comparisons discussions online.

So, back to my OP, most of the time I deal with tiny conflicts. I wanted
a quick way to look at *only* the conflicts without having to do the
search-next-search-next dance with my editor -- which is something that
vimdiff can do very well. In case anyone stumbles on to this thread
looking for something similar, I settled on the script below.

Thanks for your help/advice, David, Jacob, and Charles!

#!/bin/sh
# Use vimdiff to quickly go through Git merge conflicts.
# 
# Save your changes to the LOCAL file. MERGED will be updated if
# vimdiff exits cleanly. Use :cq to abort.
# 
# Put the following in your ~/.gitconfig
#
# [mergetool "vimdiffconflicts"]
#     cmd = unmerge.sh $BASE $LOCAL $REMOTE $MERGED
#     trustExitCode = true

if [[ -z $@ || $# != "4" ]] ; then
    echo -e "Usage: $0 \$BASE \$LOCAL \$REMOTE \$MERGED"
    exit 1
fi

BASE=$1
LOCAL=$2
REMOTE=$3
MERGED=$4

sed -e '/<<<<<<</,/=======/d' -e '/>>>>>>>/d' $MERGED > $LOCAL
sed -e '/=======/,/>>>>>>>/d' -e '/<<<<<<</d' $MERGED > $REMOTE

vim -f -d $BASE $LOCAL $REMOTE \
    -c ':diffoff' -c ':set scrollbind' -c 'wincmd l'

EC=$?

# Overwrite $MERGED
[[ $EC == "0" ]] && cat $LOCAL > $MERGED

exit $EC

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-08-18  3:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-17  4:34 Conflict markers in mergetool $LOCAL ? Seth House
2010-08-17  9:30 ` David Aguilar
2010-08-17  9:32   ` David Aguilar
2010-08-17 17:08   ` Seth House
2010-08-17 18:00     ` Jacob Helwig
2010-08-17 21:04       ` Seth House
2010-08-17 21:24         ` Charles Bailey
2010-08-18  3:22           ` Seth House

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