git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Cc: Marius Storm-Olsen <mstormo@gmail.com>,
	git@vger.kernel.org,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: git rebase -p doesn't understand -X
Date: Wed, 20 Apr 2011 18:40:04 -0500	[thread overview]
Message-ID: <20110420233949.GA10305@elie> (raw)
In-Reply-To: <BANLkTi=sW_J4LGS=XRuLrwYZTgx4GP65PA@mail.gmail.com>

Hi Martin,

Martin von Zweigbergk wrote:

> Interactive rebase uses cherry-pick internally. Jonathan added support
> for -X to that command not too long ago (in commit 67ac1e1, late last
> year), so it should be pretty straight-forward to add support for what
> you want. Maybe I'll do that in a few weeks when I get back from
> vacation.

That would be excellent.

> A related topic is _when_ to use the strategy (and strategy options).

I agree with your analysis.  In particular:

>     Example:
>
>                X
>                 \
>              A---M---B
>             /
>     ---o---O---P---Q
>
>     When the current HEAD is "B", "git rebase -i -p --onto Q O" will yield
>
>                           X
>                            \
>     ---o---O---P---Q---A'---M'---B'

I have a vague feeling that honoring --strategy and --strategy-option
would be confusing here.  The merge used in cherry-picking A does not
have much to do with the merge used to reincorporate changes from X.

Well, that is my intuition, but most of the examples I can think of
lead to the opposite conclusion!  If I use -Xrenormalize, because P
changed the line-ending style, then I will want the same option when
merging X on top.  Similarly, if I use -Xsubtree=src, because Q moved
all existing files in the source tree under src/, then with luck the
same trick will work when replaying the merge of X.

Luckily there is an exception to prove the intuition ok.  If X was the
first parent of M and I am using -Xours to sloppily favor upstream's
decisions when rebasing my history on top of it, using -Xours to favor
choices from X (which is my own) would be just plain wrong.  (Phew.)
 
>                C---D
>               /     \
>              A---B---M
>             /
>     ---o---O---P---Q
>
> which would yield
>
>                           C'---D'
>                          /      \
>     ---o---O---P---Q---A'---B'---M'

Likewise in this case.

> A more advanced solution would be recreate the merge using rerere.
[...]

Here's a vague and probably wrong idea about another way to re-create
merges.

When cherry-picking a patch (A, say), we run a three-way merge, with
A^ as merge base, A as "their" change, and the new parent for A (= Q)
as "our" change.

Maybe the same trick could work for re-creating merges.  In your first
example, run a three-way merge with M^ (= A) as merge base, M as
"their" change, and the new parent for M (= A') as "our" change.  That
only works in such a straightforward way if only one of M's parents
was rewritten, though.  More generally it could be possible to run a
sequence of three-way merges:

	base=M^1, theirs=M, ours=(M^1)' => call the result "m_1"
	base=M^2, theirs=m_1, ours=(M^2)' => call the result "m_2"
	...

At this point it gets ugly enough that just redoing the merge might be
simpler.

The main problem with rerere is that it can make mistakes.  In the
long run, I wonder if rebase could learn to take into account
something more explicit like Junio's merge-fix mechanism (see
origin/todo:Reintegrate).

Thanks; that was interesting.
Jonathan

      reply	other threads:[~2011-04-20 23:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 17:21 git rebase -p doesn't understand -X Marius Storm-Olsen
2011-04-19  9:06 ` Martin von Zweigbergk
2011-04-20 23:40   ` Jonathan Nieder [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110420233949.GA10305@elie \
    --to=jrnieder@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=martin.von.zweigbergk@gmail.com \
    --cc=mstormo@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).