From: Jan Hudec <bulb@ucw.cz>
To: Petr Baudis <pasky@suse.cz>
Cc: Joshua Ball <sciolizer@gmail.com>, git@vger.kernel.org
Subject: Re: svn user trying to recover from brain damage
Date: Wed, 9 May 2007 22:16:05 +0200 [thread overview]
Message-ID: <20070509201605.GC2982@efreet.light.src> (raw)
In-Reply-To: <20070509162259.GY4489@pasky.or.cz>
[-- Attachment #1: Type: text/plain, Size: 2825 bytes --]
On Wed, May 09, 2007 at 18:22:59 +0200, Petr Baudis wrote:
> > What is a merge? My understanding of merge comes from the SVN book,
> > where it was described as diff+apply. Diff takes 2 arguments, and
> > apply takes a 1 argument (if the patch is implicit). However, cg-merge
> > only appears to take one branch. (There again a use of the word
> > branch! Wouldn't commit or revision be a more accurate term?) Why does
> > cg-merge only take one argument? Even if I use the -b switch, I'm
> > still only up to two arguments. Where is the hidden argument?
>
> The hidden argument is your current branch. So cg-merge x will merge
> the branch 'x' to your current branch: symbolically, kind of
>
> base=-b argument | base(HEAD, x)
> apply(HEAD, diff(base, x))
>
> The word 'branch' is used in an attempt to make it all less confusing
> :-). But in fact, you can give cg-merge just id of a commit, it does not
> have to be branch name.
I believe the important thing to explain here is the BASE, as that is really
the missing argument.
Subversion Book describes merge as diff + apply. Diff takes 2 arguments - OLD
and NEW, and apply takes 2 arguments - TARGET and result of diff. That gives
us 3 arguments in total. 2 of them are passed to merge and the third is
current state of working tree.
Now in git (and in any other version control tool), merge is still diff
+ apply[1]. The TARGET is again implied by working tree. The argument to git
merge is the NEW. So where is the OLD missing?
The answer is simple: It is implied by the history! It is the most recent
common ancestor of the NEW and TARGET, or in other words latest revision that
is predecessor of both revisions being merged.
An important distinction between subversion and git here is, that in git BOTH
NEW and TARGET are considered parents of the new commit created by merge.
This means that repeated merges just work without need to look in the logs or
anywhere for what changes need to be applied.
The OLD, NEW and TARGET argument names are derived from diff/patch
terminology. More common (also in git) is to call them BASE, REMOTE and LOCAL
respectively.
It might be interesting to note, that merging is *symetrical* operation.
Swapping the LOCAL and REMOTE will give the same result, except for order in
which parents are recorded in the commit object and the order in which
conflicted sections are written out in case of conflict.
This is property is not in any way special to git. It is fundamental property
of patches. Git just cares very little about the order.
[1] The 3-way merge algorithm is not diff+apply internally, but is
equivalent to diff+apply with full context (whole file is kept), except
for way it marks conflicts.
--
Jan 'Bulb' Hudec <bulb@ucw.cz>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2007-05-09 20:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-09 15:30 svn user trying to recover from brain damage Joshua Ball
2007-05-09 16:02 ` Carl Worth
2007-05-09 16:12 ` Karl Hasselström
2007-05-09 16:22 ` Petr Baudis
2007-05-09 20:16 ` Jan Hudec [this message]
2007-05-09 16:57 ` Linus Torvalds
2007-05-09 17:43 ` J. Bruce Fields
2007-05-11 17:29 ` Jakub Narebski
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=20070509201605.GC2982@efreet.light.src \
--to=bulb@ucw.cz \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
--cc=sciolizer@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.