git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Daniel Hagerty <hag@linnaean.org>
Cc: git@vger.kernel.org
Subject: Re: git merge a b when a == b but neither == o is always a successful merge?
Date: Mon, 17 Nov 2014 15:53:04 -0500	[thread overview]
Message-ID: <20141117205304.GA15880@peff.net> (raw)
In-Reply-To: <21610.16623.746985.383838@perdition.linnaean.org>

On Mon, Nov 17, 2014 at 01:39:43PM -0500, Daniel Hagerty wrote:

> "git merge b" produces a successful merge, as both branches perform
> the "same" work.

Just to be clear, you were expecting "git merge b" to produce a
conflict?

> For the body of content in question, this is a merge conflict.  Git
> seems to have the hard-coded assumption otherwise.  I had to change
> three source files to get the result I expected, and wasn't seeing
> any indications of parameterization.

I can imagine there might be times you would like to notice this case
and visit it manually (e.g., even though the conflict would show both
sides with the same content, you might want the resolution to take the
two sides sequentially, duplicating them).  But there are also cases
where choosing the new content is helpful (e.g., one side cherry-picks a
commit from the other, then later merges; you would not want to see a
conflict there).

> Am I missing some means of getting the results I need?  Thanks!

I don't think there is an easy way to get what you want. You would have
to write a new merge 3-way strategy that handles this case differently.
And most of the file-level heavy lifting in merge strategies is done by
the low-level unpack_trees code, which handles this case. From "git help
read-tree", which describes the index-level 3-way merge:

  ·   stage 2 and 3 are the same; take one or the other (it makes no
      difference - the same work has been done on our branch in stage 2
      and their branch in stage 3)

So I think you would have to add an option to git to handle this, unless
you want to reimplement quite a lot of code in your merge strategy.

-Peff

  reply	other threads:[~2014-11-17 20:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 18:39 git merge a b when a == b but neither == o is always a successful merge? Daniel Hagerty
2014-11-17 20:53 ` Jeff King [this message]
2014-11-17 22:21   ` Daniel Hagerty
2014-11-21 18:15     ` Jeff King
2014-11-21 18:51       ` Junio C Hamano
2014-11-24 19:36         ` Daniel Hagerty

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=20141117205304.GA15880@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=hag@linnaean.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).