git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johan Herland <johan@herland.net>
Cc: Antoine Pelisse <apelisse@gmail.com>,
	Michael Haggerty <mhagger@alum.mit.edu>,
	Jeff King <peff@peff.net>, git <git@vger.kernel.org>
Subject: Re: Premerging topics
Date: Tue, 23 Apr 2013 22:48:30 -0700	[thread overview]
Message-ID: <7vzjwofpht.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: CALKQrgeGPo--cYoGZ30nSfASh4CPzqGXQojkG9Ve96NFr+LrjA@mail.gmail.com

Johan Herland <johan@herland.net> writes:

>> But P is a commit(/merge with two parents), not a blob. Can we have trees
>> pointing to commits instead of blobs ?
>
> Sort of. We do so when recording submodules in regular git trees.

You are using notes to maintain reachability, aren't you?  Because
commit objects that appears in trees are not treated as reachable
from the trees, that won't fly.

I think you guys are making it unnecessarily complex by using notes.
To record a prepared evil merge for merging branch that contains A
with another branch that contains B (assuming that the interation
between A and B is what makes the evil merge necessary, e.g. A
renames a function foo() to bar(), while B adds new callsite that
calls foo()), we can store a single commit that records the prepared
evil merge under "refs/merge-fix/$A-$B" where A and B are their
object names.

Then when merging a branch Y that contains B into our history X that
already contains A (or vice versa),

  ---o---o---A---o---X... ???
      \                  .
       \                .
        \              .
         o---B----o---Y

we can enumerate the commits that appear in "log --left-right X...Y"
on the left/right side and notice there is refs/merge-fix/$A-$B.

So the simplest implementation of "an efficient data store to record
a commit for <A,B> pair" turns out to be just a ref namespace ;-)

There may be other <C,D> pairs in X...Y history, and it probably is
the sane thing to do to replay prepackaged evil merges from older to
newer in the topological sense, but that loop would be trivial, once
we understand how to replay a single such evil merge.

The actual merge-fix data should be just a commit with a single
parent. The easiest way to prepare it would be like this:

  ---o---o---A
      \       \
       \       M---F
        \     /
         o---B

where M is the result of mechanical merge between A and B (there
could be textual conflicts and you could choose to leave them in, or
you could choose to have rerere resolve it.  As long as you do the
same when replaying this prepackaged evil merge, this choice does
not matter, but using rerere will make your life easier), and F is
the final result you would want, with semantics conflicts resolved.
In other words, in the ideal world, you would have resolved a merge
between A and B to record the tree of F.

Point "F" with refs/merge-fix/$A-$B and you are done.

When you replay this prepackaged evil merge, first you mechanically
merge X and Y without worrying about M or F to produce N.  If you
allowed rerere to resolve textual conflicts between A and B when you
recorded M, allow rerere to resolve this merge.  Otherwise leave the
textual conflict in.

  ---o---o---A---o---X
      \               \
       \               N
        \             /
         o---B---o---Y

Then on top of N, you cherry-pick F, which will bring the semantic
conflict resolution between M and F on top of N.

  ---o---o---A---o---X
      \               \
       \               N---F'
        \             /
         o---B---o---Y

Once you know the tree shape of F', then you no longer need N.  Just
amend it away and make the tree recorded in F' the result of the
merge between X and Y.

  ---o---o---A---o---X---.
      \                   \
       \                  F''
        \                /
         o---B---o---Y--.

  reply	other threads:[~2013-04-24  5:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 20:35 Premerging topics (was: [RFD] annnotating a pair of commit objects?) Antoine Pelisse
2013-04-22  9:23 ` Antoine Pelisse
2013-04-23  6:34 ` Johan Herland
2013-04-23 14:51   ` Antoine Pelisse
2013-04-23 23:06     ` Johan Herland
2013-04-24  5:48       ` Junio C Hamano [this message]
2013-04-24  6:22         ` Premerging topics Johan Herland
2013-04-24  7:14           ` Junio C Hamano
2013-04-29 19:06             ` Antoine Pelisse
2013-04-29 22:19               ` Junio C Hamano
2013-04-29 13:04         ` Antoine Pelisse
2013-04-29 15:08           ` Junio C Hamano
2013-04-23 14:53   ` Junio C Hamano
2013-04-23 15:17     ` Antoine Pelisse
2013-04-23 15:29       ` Junio C Hamano
2013-04-23 15:36         ` Antoine Pelisse

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=7vzjwofpht.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=apelisse@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johan@herland.net \
    --cc=mhagger@alum.mit.edu \
    --cc=peff@peff.net \
    /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).