git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Organov <s.organov@javad.com>
To: Junio C Hamano <gitster@pobox.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: Wed, 01 Apr 2015 14:27:28 +0300	[thread overview]
Message-ID: <87vbhgks0v.fsf@javad.com> (raw)
In-Reply-To: <xmqq8uedrtdb.fsf@gitster.dls.corp.google.com> (Junio C. Hamano's message of "Tue, 31 Mar 2015 10:04:16 -0700")

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

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

Nope. It seems like cherry-pick takes care of that:

[SCRIPT]
git init t; cd t; git config rerere.enabled false

cat > a <<EOF
Line01
Line02
Line03
Line04
Line05
Line06
Line07
Line08
Line09
EOF

git add a
git commit -aqm "A"

git checkout -b two-chunks
sed -i -e 's/Line04/Line04_1/' a
sed -i -e 's/Line08/Line08_1/' a
git commit -aqm "A_04_08_1"

git checkout master
sed -i -e 's/Line04/Line04_1/' a
git commit -aqm "A_04_1"

git cherry-pick two-chunks

git log --oneline
cat a
[/SCRIPT]

What do I miss?

-- Sergey.

  reply	other threads:[~2015-04-01 11:27 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
2015-04-01 11:27             ` Sergey Organov [this message]
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=87vbhgks0v.fsf@javad.com \
    --to=s.organov@javad.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=sschuberth@gmail.com \
    /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).