@@ -320,17 +320,22 @@ <h2>NAME</h2>
320320</ div >
321321< h2 > SYNOPSIS</ h2 >
322322< div class ="sectionbody ">
323- < div class ="para "> < p > < em > git merge-base</ em > [--all] <commit> <commit></ p > </ div >
323+ < div class ="para "> < p > < em > git merge-base</ em > [--all] <commit> <commit>… </ p > </ div >
324324</ div >
325325< h2 id ="_description "> DESCRIPTION</ h2 >
326326< div class ="sectionbody ">
327- < div class ="para "> < p > < em > git-merge-base</ em > finds as good a common ancestor as possible between
328- the two commits. That is, given two commits A and B, < tt > git merge-base A
329- B</ tt > will output a commit which is reachable from both A and B through
330- the parent relationship.</ p > </ div >
331- < div class ="para "> < p > Given a selection of equally good common ancestors it should not be
332- relied on to decide in any particular way.</ p > </ div >
333- < div class ="para "> < p > The < em > git-merge-base</ em > algorithm is still in flux - use the source…</ p > </ div >
327+ < div class ="para "> < p > < em > git-merge-base</ em > finds best common ancestor(s) between two commits to use
328+ in a three-way merge. One common ancestor is < em > better</ em > than another common
329+ ancestor if the latter is an ancestor of the former. A common ancestor
330+ that does not have any better common ancestor than it is a < em > best common
331+ ancestor</ em > , i.e. a < em > merge base</ em > . Note that there can be more than one
332+ merge bases between two commits.</ p > </ div >
333+ < div class ="para "> < p > Among the two commits to compute their merge bases, one is specified by
334+ the first commit argument on the command line; the other commit is a
335+ (possibly hypothetical) commit that is a merge across all the remaining
336+ commits on the command line. As the most common special case, giving only
337+ two commits from the command line means computing the merge base between
338+ the given two commits.</ p > </ div >
334339</ div >
335340< h2 id ="_options "> OPTIONS</ h2 >
336341< div class ="sectionbody ">
@@ -340,12 +345,62 @@ <h2 id="_options">OPTIONS</h2>
340345</ dt >
341346< dd >
342347< p >
343- Output all common ancestors for the two commits instead of
344- just one.
348+ Output all merge bases for the commits, instead of just one.
345349</ p >
346350</ dd >
347351</ dl > </ div >
348352</ div >
353+ < h2 id ="_discussion "> DISCUSSION</ h2 >
354+ < div class ="sectionbody ">
355+ < div class ="para "> < p > Given two commits < em > A</ em > and < em > B</ em > , < tt > git merge-base A B</ tt > will output a commit
356+ which is reachable from both < em > A</ em > and < em > B</ em > through the parent relationship.</ p > </ div >
357+ < div class ="para "> < p > For example, with this topology:</ p > </ div >
358+ < div class ="literalblock ">
359+ < div class ="content ">
360+ < pre > < tt > o---o---o---B
361+ /
362+ ---o---1---o---o---o---A</ tt > </ pre >
363+ </ div > </ div >
364+ < div class ="para "> < p > the merge base between < em > A</ em > and < em > B</ em > is < em > 1</ em > .</ p > </ div >
365+ < div class ="para "> < p > Given three commits < em > A</ em > , < em > B</ em > and < em > C</ em > , < tt > git merge-base A B C</ tt > will compute the
366+ merge base between < em > A</ em > and an hypothetical commit < em > M</ em > , which is a merge
367+ between < em > B</ em > and < em > C</ em > . For example, with this topology:</ p > </ div >
368+ < div class ="literalblock ">
369+ < div class ="content ">
370+ < pre > < tt > o---o---o---o---C
371+ /
372+ / o---o---o---B
373+ / /
374+ ---2---1---o---o---o---A</ tt > </ pre >
375+ </ div > </ div >
376+ < div class ="para "> < p > the result of < tt > git merge-base A B C</ tt > is < em > 1</ em > . This is because the
377+ equivalent topology with a merge commit < em > M</ em > between < em > B</ em > and < em > C</ em > is:</ p > </ div >
378+ < div class ="literalblock ">
379+ < div class ="content ">
380+ < pre > < tt > o---o---o---o---o
381+ / \
382+ / o---o---o---o---M
383+ / /
384+ ---2---1---o---o---o---A</ tt > </ pre >
385+ </ div > </ div >
386+ < div class ="para "> < p > and the result of < tt > git merge-base A M</ tt > is < em > 1</ em > . Commit < em > 2</ em > is also a
387+ common ancestor between < em > A</ em > and < em > M</ em > , but < em > 1</ em > is a better common ancestor,
388+ because < em > 2</ em > is an ancestor of < em > 1</ em > . Hence, < em > 2</ em > is not a merge base.</ p > </ div >
389+ < div class ="para "> < p > When the history involves criss-cross merges, there can be more than one
390+ < em > best</ em > common ancestors between two commits. For example, with this
391+ topology:</ p > </ div >
392+ < div class ="literalblock ">
393+ < div class ="content ">
394+ < pre > < tt > ---1---o---A
395+ \ /
396+ X
397+ / \
398+ ---2---o---o---B</ tt > </ pre >
399+ </ div > </ div >
400+ < div class ="para "> < p > both < em > 1</ em > and < em > 2</ em > are merge-base of A and B. Neither one is better than
401+ the other (both are < em > best</ em > merge base). When < tt > --all</ tt > option is not given,
402+ it is unspecified which best one is output.</ p > </ div >
403+ </ div >
349404< h2 id ="_author "> Author</ h2 >
350405< div class ="sectionbody ">
351406< div class ="para "> < p > Written by Linus Torvalds <torvalds@osdl.org></ p > </ div >
@@ -360,7 +415,7 @@ <h2 id="_git">GIT</h2>
360415</ div >
361416< div id ="footer ">
362417< div id ="footer-text ">
363- Last updated 2008-07-06 05:16:53 UTC
418+ Last updated 2008-08-21 10:34:00 UTC
364419</ div >
365420</ div >
366421</ body >
0 commit comments