git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Geoffrey Lee <geoffreyj.lee@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: How to create patches for a merge?
Date: Thu, 18 Feb 2010 10:10:13 -0800	[thread overview]
Message-ID: <7veikifm9m.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <83d7aaa41002180340p2f9b7241h9c220b84ec5dd1d@mail.gmail.com> (Geoffrey Lee's message of "Thu\, 18 Feb 2010 03\:40\:07 -0800")

Geoffrey Lee <geoffreyj.lee@gmail.com> writes:

> This produces a merge conflict. In this scenario, "git format-patch
> master..bar" only produces 3 patches, omitting "Commit M". How do I
> deal with this?

There is no provision for communicating how a conflict is resolved over
patches.  The answer to your "How do I deal with *this*" question would be
"It is up to you.", if your "*this*" is "I want to communicate this as a
patch".  The steps to deal with "*this*" may go like this:

 - Think what shape of patch you want to see in order to convey what
   "Commit M" did to the recipient of your patch series.  First, try to
   construct it, by hand if necessary, as a design of such a feature.

 - How would a recipient "apply" such a patch?  As commonly used "patch"
   implementations, including "git apply", may not be able to read the
   above format, and they would certainly not create a merge commit, so
   you need to design the recieving side as well.

 - Then implement them ;-)

The best I think of offhand to reproduce

     B---M---D
    /   /
   A---C

might go like this:

 (1) Emit diff between (A,B) as usual;

 (2) Emit diff between (A,C) as usual, but with additional information
     usually not found in regular patches to help recipient that this
     should be applied to the same commit as (1) is applied to;

 (3) Emit diff between (B,M) and (C,M), but make sure that they won't be
     seen as a patch to be applied by ordinary "patch" programs to avoid
     mistakes at the recipient side.  Include some way to tell the
     recipient that these two "patches" need to be applied to the results
     of applying (1) and (2), and that the result needs to be recorded as
     a merge between them.

 (4) Emit D as usual;

Then the recipient would start from something that resembles A (call it X)
and do the following:

 (5) Apply (1); call that result B'

       B'
      /
     X

 (6) Apply (2), following that additional insn to apply the patch to the
     base of (5); call that result C'

       B'
      /
     X---C'

 (7) Apply (B,M) half of (3) to B' and call it M'


       B'..M'
      /
     X---C'

 (8) Apply (C,M) half of (3) to C' and call it M"

       B'--M' M"
      /      .
     X------C'

 (9) If M' and M" do not match (which can happen when A and X are majorly
     different), merge them using X as their common ancestor, and resolve
     conflicts as necessary, and call the result M'".

     If M' and M" do match, be happy and call either of them M'".

         B'..M'..M'"                B'..M'"
        /       .       or         /   . 
       /       M"                 X---C'
      /       .
     X-------C'

 (10) Record M'" as children of B' and C'.

       B'--M'"
      /   /
     X---C'

 (11) Apply (4); call that result D'

        B'--M'"-D'
      /   /
     X---C'

and you are done.

  reply	other threads:[~2010-02-18 18:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 11:40 How to create patches for a merge? Geoffrey Lee
2010-02-18 18:10 ` Junio C Hamano [this message]
2010-02-18 20:37 ` Jeff King
2010-02-19 10:25   ` Geoffrey Lee
2010-02-20 17:39     ` Clemens Buchacher

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=7veikifm9m.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=geoffreyj.lee@gmail.com \
    --cc=git@vger.kernel.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).