From 99f1c04be09d73a40ef0a37c6868969d40391196 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 30 Jul 2008 07:04:43 +0200 Subject: documentation: merge-base: explain "git merge-base" with more than 2 args Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- Documentation/git-merge-base.txt | 77 ++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 11 deletions(-) (limited to 'Documentation/git-merge-base.txt') diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 1a7ecbf8f3..2f0c5259e0 100644 --- a/Documentation/git-merge-base.txt +++ b/Documentation/git-merge-base.txt @@ -8,26 +8,81 @@ git-merge-base - Find as good common ancestors as possible for a merge SYNOPSIS -------- -'git merge-base' [--all] +'git merge-base' [--all] ... DESCRIPTION ----------- -'git-merge-base' finds as good a common ancestor as possible between -the two commits. That is, given two commits A and B, `git merge-base A -B` will output a commit which is reachable from both A and B through -the parent relationship. +'git-merge-base' finds best common ancestor(s) between two commits to use +in a three-way merge. One common ancestor is 'better' than another common +ancestor if the latter is an ancestor of the former. A common ancestor +that does not have any better common ancestor than it is a 'best common +ancestor', i.e. a 'merge base'. Note that there can be more than one +merge bases between two commits. -Given a selection of equally good common ancestors it should not be -relied on to decide in any particular way. - -The 'git-merge-base' algorithm is still in flux - use the source... +Among the two commits to compute their merge bases, one is specified by +the first commit argument on the command line; the other commit is a +(possibly hypothetical) commit that is a merge across all the remaining +commits on the command line. As the most common special case, giving only +two commits from the command line means computing the merge base between +the given two commits. OPTIONS ------- --all:: - Output all common ancestors for the two commits instead of - just one. + Output all merge bases for the commits, instead of just one. + +DISCUSSION +---------- + +Given two commits 'A' and 'B', `git merge-base A B` will output a commit +which is reachable from both 'A' and 'B' through the parent relationship. + +For example, with this topology: + + o---o---o---B + / + ---o---1---o---o---o---A + +the merge base between 'A' and 'B' is '1'. + +Given three commits 'A', 'B' and 'C', `git merge-base A B C` will compute the +merge base between 'A' and an hypothetical commit 'M', which is a merge +between 'B' and 'C'. For example, with this topology: + + o---o---o---o---C + / + / o---o---o---B + / / + ---2---1---o---o---o---A + +the result of `git merge-base A B C` is '1'. This is because the +equivalent topology with a merge commit 'M' between 'B' and 'C' is: + + + o---o---o---o---o + / \ + / o---o---o---o---M + / / + ---2---1---o---o---o---A + +and the result of `git merge-base A M` is '1'. Commit '2' is also a +common ancestor between 'A' and 'M', but '1' is a better common ancestor, +because '2' is an ancestor of '1'. Hence, '2' is not a merge base. + +When the history involves criss-cross merges, there can be more than one +'best' common ancestors between two commits. For example, with this +topology: + + ---1---o---A + \ / + X + / \ + ---2---o---o---B + +both '1' and '2' are merge-base of A and B. Neither one is better than +the other (both are 'best' merge base). When `--all` option is not given, +it is unspecified which best one is output. Author ------ -- cgit v1.2.3 From 29b802aae6213d02879d21aabac1a8d2e035b583 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Tue, 9 Dec 2008 07:23:51 +0100 Subject: Improve language in git-merge.txt and related docs Improve some minor language and format issues like hyphenation, phrases, spacing, word order, comma, attributes. Signed-off-by: Junio C Hamano --- Documentation/git-merge-base.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'Documentation/git-merge-base.txt') diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 2f0c5259e0..767486c770 100644 --- a/Documentation/git-merge-base.txt +++ b/Documentation/git-merge-base.txt @@ -16,15 +16,15 @@ DESCRIPTION 'git-merge-base' finds best common ancestor(s) between two commits to use in a three-way merge. One common ancestor is 'better' than another common ancestor if the latter is an ancestor of the former. A common ancestor -that does not have any better common ancestor than it is a 'best common +that does not have any better common ancestor is a 'best common ancestor', i.e. a 'merge base'. Note that there can be more than one -merge bases between two commits. +merge base for a pair of commits. -Among the two commits to compute their merge bases, one is specified by +Among the two commits to compute the merge base from, one is specified by the first commit argument on the command line; the other commit is a (possibly hypothetical) commit that is a merge across all the remaining -commits on the command line. As the most common special case, giving only -two commits from the command line means computing the merge base between +commits on the command line. As the most common special case, specifying only +two commits on the command line means computing the merge base between the given two commits. OPTIONS @@ -47,7 +47,7 @@ For example, with this topology: the merge base between 'A' and 'B' is '1'. Given three commits 'A', 'B' and 'C', `git merge-base A B C` will compute the -merge base between 'A' and an hypothetical commit 'M', which is a merge +merge base between 'A' and a hypothetical commit 'M', which is a merge between 'B' and 'C'. For example, with this topology: o---o---o---o---C @@ -71,8 +71,7 @@ common ancestor between 'A' and 'M', but '1' is a better common ancestor, because '2' is an ancestor of '1'. Hence, '2' is not a merge base. When the history involves criss-cross merges, there can be more than one -'best' common ancestors between two commits. For example, with this -topology: +'best' common ancestor for two commits. For example, with this topology: ---1---o---A \ / @@ -80,8 +79,8 @@ topology: / \ ---2---o---o---B -both '1' and '2' are merge-base of A and B. Neither one is better than -the other (both are 'best' merge base). When `--all` option is not given, +both '1' and '2' are merge-bases of A and B. Neither one is better than +the other (both are 'best' merge bases). When the `--all` option is not given, it is unspecified which best one is output. Author -- cgit v1.2.3 From 995bdc73fe0e28d622af0897440f0ea298345585 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 5 Aug 2009 09:59:19 +0200 Subject: git-merge-base/git-show-branch: Cleanup documentation and usage Make sure that usage strings and documentation coincide with each other and with the actual code. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- Documentation/git-merge-base.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Documentation/git-merge-base.txt') diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 767486c770..00e400353c 100644 --- a/Documentation/git-merge-base.txt +++ b/Documentation/git-merge-base.txt @@ -8,12 +8,12 @@ git-merge-base - Find as good common ancestors as possible for a merge SYNOPSIS -------- -'git merge-base' [--all] ... +'git merge-base' [-a|--all] ... DESCRIPTION ----------- -'git-merge-base' finds best common ancestor(s) between two commits to use +'git merge-base' finds best common ancestor(s) between two commits to use in a three-way merge. One common ancestor is 'better' than another common ancestor if the latter is an ancestor of the former. A common ancestor that does not have any better common ancestor is a 'best common @@ -29,6 +29,7 @@ the given two commits. OPTIONS ------- +-a:: --all:: Output all merge bases for the commits, instead of just one. -- cgit v1.2.3 From f621a8454d19d17fe46e6951b7e3d22bebd92aba Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Wed, 5 Aug 2009 09:59:20 +0200 Subject: git-merge-base/git-show-branch --merge-base: Documentation and test Currently, the documentation suggests that 'git merge-base -a' and 'git show-branch --merge-base' are equivalent (in fact it claims that the former cannot handle more than two revs). Alas, the handling of more than two revs is very different. Document this by tests and correct the documentation to reflect this. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- Documentation/git-merge-base.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Documentation/git-merge-base.txt') diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 00e400353c..ce5b369985 100644 --- a/Documentation/git-merge-base.txt +++ b/Documentation/git-merge-base.txt @@ -27,6 +27,10 @@ commits on the command line. As the most common special case, specifying only two commits on the command line means computing the merge base between the given two commits. +As a consequence, the 'merge base' is not necessarily contained in each of the +commit arguments if more than two commits are specified. This is different +from linkgit:git-show-branch[1] when used with the `--merge-base` option. + OPTIONS ------- -a:: -- cgit v1.2.3