git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Joshua Jensen <jjensen@workspacewhiz.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	Jonathan Steinert <hachi@kuiki.net>
Subject: Re: git rebase --preserve-merges seems to not work
Date: Thu, 9 Sep 2010 07:51:04 +0200	[thread overview]
Message-ID: <20100909055104.GA21004@atjola.homenet> (raw)
In-Reply-To: <4C886DF3.8050903@workspacewhiz.com>

On 2010.09.08 23:17:39 -0600, Joshua Jensen wrote:
> # Commit 'd' is something I would pull --rebase from the server
> before I push.
> $ git lg --all
> *   472fd93 - (HEAD, bc-merge) Merge commit 'c' into HEAD (3 seconds ago)
> |\
> | * d132c87 - (c) c (2 minutes ago)
> | * 4a88fd1 - b (2 minutes ago)
> |/
> | * 6abf527 - (d) d (2 minutes ago)
> |/
> * b576660 - (a, master) a (3 minutes ago)
> 
> 
> # Here is the rebase with the --preserve-merges option.
> $ git rebase --preserve-merges d
> Rebasing (n/3)
> Successfully rebased and updated detached HEAD.
> 
> # Of course, bc-merge is an orphaned branch.  Its changes got
> replayed on top of 'd'.

Yup, and the "problem" is, that both sides of the merge got replayed.

> # Note the merge commit with the description "Merge commit 'c' into
> HEAD" is missing.

Because the merge could be resolved as a fast-forward, as it merges the
replayed commits b' and c', not the originals.

> $ git lg --all
> * 2c93a8a - (HEAD) c (11 seconds ago)
> * 2b98bc6 - b (11 seconds ago)
> * 6abf527 - (d) d (3 minutes ago)
> | *   472fd93 - (bc-merge) Merge commit 'c' into HEAD (74 seconds ago)
> | |\
> |/ /
> | * d132c87 - (c) c (3 minutes ago)
> | * 4a88fd1 - b (3 minutes ago)
> |/
> * b576660 - (a, master) a (4 minutes ago)

What you actually wanted to replay is just the first-parent history,
redoing the merges with their respective original second parent.
Jonathan (Cc'ed) had the same problem about a month ago.

The "first parent" thing isn't that well defined, criss-cross merges
combined with some unfortunate fast-forwards will easily make the
first-parent history become the one that you didn't mean (ask any
git-svn users that dared to use "git merge" without fully understanding
how git-svn uses the history ;-)), but it works in this special case.
And with that special case in mind (and admittedly probably not thinking
much further) I came up with this patch a few years ago:

http://marc.info/?l=git&m=119379735525213&w=2

It was not my itch to scratch though, so I never got around to get it
included, and of course it doesn't apply cleanly anymore. I tried to
give some hints to Jonathan ("hachi") on #git on how to update the patch
to make it apply again:

http://colabti.de/irclogger/irclogger_log/git?date=2010-08-20#l1241

Feel free to pick up from there...

Björn

  reply	other threads:[~2010-09-09  5:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-09  5:17 git rebase --preserve-merges seems to not work Joshua Jensen
2010-09-09  5:51 ` Björn Steinbrink [this message]
2010-09-09  6:26   ` Joshua Jensen

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=20100909055104.GA21004@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=hachi@kuiki.net \
    --cc=jjensen@workspacewhiz.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).