public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Sergey Organov <sorganov@gmail•com>
Cc: Johannes Sixt <j6t@kdbg•org>,
	Sebastian Schuberth <sschuberth@gmail•com>,
	Git Mailing List <git@vger•kernel.org>
Subject: Re: [PATCH] docs: Clarify what git-rebase's "--preserve-merges" does
Date: Tue, 31 Mar 2015 10:04:16 -0700	[thread overview]
Message-ID: <xmqq8uedrtdb.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <xmqqh9t1rv0r.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Tue, 31 Mar 2015 09:28:36 -0700")

Junio C Hamano <gitster@pobox•com> writes:

> I wonder if it will be the right way to get a correct result to
> apply the difference to go from B to Z on top of an old commit when
> you are side-porting.
>
> Imagine you want to backport the same X-Y history by redoing the
> merge Z on top of another child of O (i.e. A's sibling).  That is,
> you start from this:
>
>
>          X---Y
>         /     \
>    O---A---B---Z---
>     \
>      M---N
>
> and would want to create this:
>     
>     
>    O           X'--Y'
>     \         /     \    
>      M---N---A'--B'--Z'--
>
> As long as everything down to the merge-base of the parents of the
> original merge (in this example, merge-base across Y and B that are
> Z's parents, which is A) is being transplanted, "apply the
> difference going from B to Z, on top of B', to obtain Z'" should
> work, I would think.

And just after I send the message because I needed to catch a bus, I
notice that there is a problem.

Actually, "replay diff going from B to Z instead of merging" must be
done very carefully.  Imagine when Y in the original history were a
cherry-pick of M.  What you would be creating would look more like
this instead:
     
    O           X'--.
     \         /     \    
      M---N---A'--B'--Z'--

because Y' becomes a no-op, as the transplanted history already has
M applied.  But the original "diff going from B to Z" has the effect
of M already in there.  You would end up adding the same hunk twice
without noticing.  You somehow need to come up with a way to deal
with this.

If you did a real merge between X' and B' to recreate Z', you would
not have such a problem.

One way to be careful when recreating Z' out of Z might be:

    - Retry a merge between the original B and Y, with conflict
      markers intact;

    - Compare the result with what is recorded in Z.  The
      differences are textual conflict resolution and evil merge
      changes;

    - Now try a merge between B' and Y', with conflict markers
      intact;

    - Apply the difference you obtained in the second step to the
      result of the third step.

which is essentially the same as what rerere does.

  parent reply	other threads:[~2015-03-31 17:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 13:04 [PATCH] docs: Clarify what git-rebase's "--preserve-merges" does Sebastian Schuberth
2015-03-26 18:18 ` Junio C Hamano
2015-03-26 20:28   ` Sebastian Schuberth
2015-03-26 20:55     ` Junio C Hamano
2015-03-26 21:17   ` Sergey Organov
2015-03-26 21:41     ` Johannes Sixt
2015-03-31  9:13       ` Sergey Organov
2015-03-31 16:28         ` Junio C Hamano
2015-03-31 17:03           ` Sergey Organov
2015-03-31 17:04           ` Junio C Hamano [this message]
2015-04-01 11:27             ` Sergey Organov
2015-04-01 17:03               ` Junio C Hamano
2015-04-02  9:53                 ` Sergey Organov
2015-03-30  9:29   ` Sebastian Schuberth
2015-03-30 17:23     ` Junio C Hamano
2015-03-30 19:42       ` Sebastian Schuberth
2015-03-30 19:58         ` Junio C Hamano
2015-03-30 20:23           ` Junio C Hamano
2015-03-30 21:09             ` Sebastian Schuberth

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=xmqq8uedrtdb.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=j6t@kdbg$(echo .)org \
    --cc=sorganov@gmail$(echo .)com \
    --cc=sschuberth@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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