git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: "Bernhard R. Link" <brlink@debian.org>
Cc: git@vger.kernel.org
Subject: Re: equal-tree-merges as way to make rebases fast-forward-able
Date: Tue, 01 Dec 2009 12:50:13 +0100	[thread overview]
Message-ID: <4B1502F5.1060100@alum.mit.edu> (raw)
In-Reply-To: <cover.1259524136.git.brlink@debian.org>

Bernhard R. Link wrote:
> Example 1:
> 
> Let's assume you maintain such a regularily-rebased branch that you
> want to be able to publish (or pull from other repositories for example
> on your laptop):
> 
> o=m=o=o=master
>    \
>     a=b=c=d=e=feature
> 
> with this patch you can do "git rebase -eqt master" and get:
> 
>               a'=b'=c'=d'=e'=feature'=eqt
>              /                       /
> o=m=o=o=master--------              /
>    \                  \            /
>     a=b=c=d=e=feature--merge-------

Actually, there is more information that can be retained about this
rebase operation.  Your scheme records the fact that (a+b+c+d+e+merge)
== (o+o+a'+b'+c'+d'+e'), which is certainly true.  But in the process of
rebasing, the user has (implicitly or explicitly) resolved conflicts in
transforming each of the patches a -> a', b -> b', etc.  In fact, the
patch a' is itself a merge between a and master; b' is a merge between b
and a'; etc.  If you record each of these merges individually, the
result looks like this:

o=m=o=o=master
   \      \
    \      a'=b'=c'=d'=e'=feature'
     \    /  /  /  /  /
      ---a==b==c==d==e==feature

There are advantages to retaining all of this history:

* It faithfully represents intermediate steps of the rebase.

* There is no need for special "merge" and "eqt" merge commits affecting
an arbitrary group of feature patches; each of the rebased patches is
treated identically.

* There is a direct ancestry connection from the "new version" to the
"old version" of each patch; for example, it is easy to see that c' is a
new version of c and to compute the corresponding interdiffs.

* There are situations where the additional info can help git choose
better merge bases in the case of merge/rebases across three or more
repositories.  For example, somebody who is developing a subfeature
based on the feature branch can merge/rebase changes from both feature
and master without causing utter chaos.

The "historical" version of the feature branch should be omitted from
most git output as you have suggested, but this would be best
implemented by marking the "historical" ancestor with some extra flag in
each merge commit.

> Example 2:
> 
> Let's assume you have a feature branch like
> 
> o=master
>    \
>     a=b=c=d=e=f
> 
> Assume you just commited "f" which fixes a bug introduced by "b". [...]
> 
> So with this patches you can do "git rebase -i --eqt" and squash f into b
> and get:
> 
> o=master
>    \
>     a=b=c=d=e=f---
>      \            \
>       b+f=c'=d'=e'=eqt

This case can also record additional information:

o=master
   \
    a=b===c==d=e=f
       \   \  \   \
        b+f=c'=d'==e'

Here the new DAG cannot represent *all* ancestry information (namely,
that b+f, c', and d' also include the original patch f), but it does
accurately reflect useful information such as that c' includes c and
that e' includes e and f.

I wrote some blog entries about rebasing-with-history that might be
interesting [1-3].

Michael

[1]
http://softwareswirl.blogspot.com/2009/04/truce-in-merge-vs-rebase-war.html
[2]
http://softwareswirl.blogspot.com/2009/08/upstream-rebase-just-works-if-history.html
[3]
http://softwareswirl.blogspot.com/2009/08/rebase-with-history-implementation.html

      parent reply	other threads:[~2009-12-01 11:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-30 14:43 equal-tree-merges as way to make rebases fast-forward-able Bernhard R. Link
2009-11-30 14:43 ` [PATCH 1/7] add new command git equal-tree-marker Bernhard R. Link
2009-11-30 15:36   ` Michael J Gruber
2009-11-30 14:44 ` [PATCH 2/7] add option to only visit the first parent of a equal tree merge Bernhard R. Link
2009-11-30 14:44 ` [PATCH 3/7] format-patch defaults to --first-equal-tree-only Bernhard R. Link
2009-11-30 14:44 ` [PATCH 4/7] support equal tree merges in interactive rebase Bernhard R. Link
2009-11-30 14:45 ` [PATCH 5/7] make rebase -m equal tree marker aware Bernhard R. Link
2009-11-30 14:45 ` [PATCH 6/7] add support for creating equal tree markers after rebase Bernhard R. Link
2009-11-30 14:45 ` [PATCH 7/7] add support for creating equal tree markers to rebase -i Bernhard R. Link
2009-11-30 15:10 ` equal-tree-merges as way to make rebases fast-forward-able Sverre Rabbelier
2009-11-30 15:31 ` Paolo Bonzini
2009-11-30 16:22   ` Bernhard R. Link
2009-11-30 15:35 ` Michael J Gruber
2009-11-30 15:59 ` Michael J Gruber
2009-11-30 16:54   ` Bernhard R. Link
2009-11-30 17:19 ` Johannes Schindelin
2009-11-30 18:18 ` Junio C Hamano
2009-11-30 18:55   ` Bernhard R. Link
2009-12-01  0:25     ` Junio C Hamano
2009-11-30 19:26   ` Johannes Sixt
2009-11-30 20:32     ` Junio C Hamano
2009-11-30 22:12   ` Nanako Shiraishi
2009-12-01  0:20     ` Junio C Hamano
2009-12-01  0:23       ` [PATCH] git-merge: a deprecation notice of the ancient command line syntax Junio C Hamano
2009-12-01  3:55         ` Nicolas Pitre
2009-12-01  4:07           ` Junio C Hamano
2009-12-02 10:20       ` equal-tree-merges as way to make rebases fast-forward-able Nanako Shiraishi
2009-12-02 18:03         ` Junio C Hamano
2009-12-01 11:50 ` Michael Haggerty [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=4B1502F5.1060100@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=brlink@debian.org \
    --cc=git@vger.kernel.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).