From: Jakub Narebski <jnareb@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stefan Bucur <stefan.bucur@gmail.com>, git@vger.kernel.org
Subject: Re: Wrong file diff for merge conflict
Date: Sun, 05 Jul 2009 12:22:22 -0700 (PDT) [thread overview]
Message-ID: <m3vdm7ue8k.fsf@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.01.0907051113240.3210@localhost.localdomain>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Sat, 4 Jul 2009, Stefan Bucur wrote:
> >
> > http://pastebin.ca/1483228
> >
> > The problem is with the last diff in the file, where the left portion is empty,
> > and the right portion contains code which already was marked as merged (common),
> > right before the start of the diff. Therefore, the mark at line 127 should
> > really have been before line 114.
> >
> > Is this a bug or I am missing something?
>
> I suspect (but without the origin files/history I can't verify) that what
> happens is that the "successfully merged" code was seen as a fully new
> snippet of code (probably due to getting re-indented?), and the other part
> of that action on that branch was the removal of the old code.
>
> That _removal_ is then shown as a conflict against the other branch, which
> presumably didn't re-indent things (of course, it could be exactly the
> other way around too), and so now you end up having the "conflict" being
> seen as "one branch removes this code (empty conflict part), the other one
> presumably changed it some way".
>
> Is that what you wanted? Obviously not. To you, the conflict makes no
> sense. You're a human, who tries to understand what wen't wrong, and to
> you, the end result of the conflict resolution makes no sense.
[...]
> - Don't rely so heavily on just the traditional three-way merge result.
>
> This is what I personally do. The trivial 3-way merge result is
> wondeful for the truly trivial merges, when it gives trivial results
> that are easy to fix up. But let's face it, the traditional 3-way merge
> result just sucks for anything more complicated. When you have an empty
> side on one of the conflicts, is that because the other side added
> everything, or is it because oen side removed it? Or is it, like in
> this case, simply because trivially similar lines got the whole diff
> confused about which parts didn't change at all?
>
> The good news is that git does have a few nice merge tools. One is
> "git diff", which actually shows way more than the trivial three-way
> end result, in that you can diff against either side, and by default it
> does that fairly complex "diff against both sides" thing that is also
> quite useful once you get used to it.
>
> Another is "gitk --merge [filename]" which is wonderful as a tool to
> see what both sides actually did, to figure out what the intent of both
> branches were when the three-way merge result is just noise.
There is also "git mergetool" which runs graphical merge tool of your
choice. It can be easier to work with GUI here.
And git also supports diff3 conflict merge markers, which shows our
and their side, and also the ancestor side; in your case it would make
easy to distinguish between 'one side added' and 'other side removed'.
You can get it using
$ git checkout --conflict=diff3 <file>
(where <file> can be '.'). You would need modern git (post 1.6.2
I think) for that.
> The right answer is probably some combination of "all of the above". In
> the meantime, right now, only the last one is something git itself will
> help you with.
--
Jakub Narebski
Poland
ShadeHawk on #git
next prev parent reply other threads:[~2009-07-05 19:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-04 7:53 Wrong file diff for merge conflict Stefan Bucur
2009-07-05 18:43 ` Linus Torvalds
2009-07-05 19:22 ` Jakub Narebski [this message]
2009-07-05 19:23 ` Junio C Hamano
2009-07-05 22:23 ` Stefan Bucur
2009-07-06 0:33 ` Linus Torvalds
2009-07-06 14:44 ` Stefan Bucur
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=m3vdm7ue8k.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=stefan.bucur@gmail.com \
--cc=torvalds@linux-foundation.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).