git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jon Seymour <jon.seymour@gmail.com>
To: git@vger.kernel.org
Cc: tyler@monkeypox.org
Subject: Re: Rebasing with merges and conflict resolutions
Date: Sat, 27 Mar 2010 04:36:24 +1100	[thread overview]
Message-ID: <2cfc40321003261036n7bfe402co8084824f6222a841@mail.gmail.com> (raw)
In-Reply-To: <20100326031111.GB27737@kiwi.sharlinx.com>

You might find this post from a few weeks back interesting:

    http://permalink.gmane.org/gmane.comp.version-control.git/140510

Unfortunately, I haven't had time to reproduce a robust implementation
of the ideas, but I have exercised the algorithm manually a few times
and it works quite well.

The basic idea is that you split the merge history into segments
(where a segment is a single linear series of commits). Then starting
from the oldest you rewrite:

A----B---M
  \---C---/

as:

A---B---e---C'---e'---M'

where e is a compensation that allows e to be automatically rebased
onto B without merge conflicts and e' restores the tree to the point
it was an M so that tree(M) and tree(M') are identical. See the
original post for working out how to construct e and e'. The basic
idea is you find the confllcts that would result if you attempted
rebase C on B, then reset part of the tree in such a way that the
conflicts are removed. e' then is the patch that restores tree(C') to
tree(M)

You have to realise that the trees between e and e' will be
inconsistent because part of the tree is shifted back in time in order
to allow the C to rebase cleanly.

Once the history is linearised in this way, it is often (but not
always) possible to reorder and then squash the commits in  e --- C'
--- e' such away that the consistency of the tree in this region is
restored.

if you repeat this algorithm recursively for each merge in the merge
history you can flatten the entire merge history out into a linear
series of commits. This can be complete and automatic, alhough to
obtain completeness you do lose consistency at certain well-delimited
points in the history. Consistency can be restored, if required, by
manually rebasing the linearised history in a single pass at the end.

I do intend to commit the algorithm to code at some point, but haven't
had a chance to do so yet. See ( http://github.com/jonseymour/hammer)
for a readme that also describes the idea in more detail

jon.

On Fri, Mar 26, 2010 at 2:11 PM, R. Tyler Ballance <tyler@monkeypox.org> wrote:
> I am trying to use rebase to straighten out a couple topic branches' histories
> and running into nothing but troubles and I'm wondering if:
>   a) I'm doing it wrong (highly likely)
>   b) what I want is not possible
>   c) banana!
>
> Two contributors worked in tandem on a particular project, constantly merging
> back and forth between each other creating a history of 118 commits total with
> 37 of them being merge commits, 7 of those merge commits having conflict
> resolutions involved.
>
> I would /like/ to rebase those into a more linear revision history, but I
> can't seem to find any set of commands that doesn't have me:
>   a) Manually re-doing every conflict resolution and merge (git rebase -p master)
>   b) Drastically diverging from the original topic branch and entering some
>      sort of mergeless hell (git rebase master)
>
>
> Is it even possible to straighten this out without a massive rework of these
> commits?
>
> In the future, is there a better way for two developers to work in the same
> back-and-forth fashion (code ping pong!) without leading to *heavily* merged
> histories that are unpossible to untangle?
>
>
> Halp!
>
>
> Cheers,
> -R. Tyler Ballance
> --------------------------------------
>  Jabber: rtyler@jabber.org
>  GitHub: http://github.com/rtyler
> Twitter: http://twitter.com/agentdero
>   Blog: http://unethicalblogger.com
>
>

      parent reply	other threads:[~2010-03-26 17:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-26  3:11 Rebasing with merges and conflict resolutions R. Tyler Ballance
2010-03-26  7:02 ` Johannes Sixt
2010-03-26 17:16   ` R. Tyler Ballance
2010-03-26 18:11     ` Jon Seymour
2010-03-26 17:36 ` Jon Seymour [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

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

  git send-email \
    --in-reply-to=2cfc40321003261036n7bfe402co8084824f6222a841@mail.gmail.com \
    --to=jon.seymour@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tyler@monkeypox.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).