]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-merge-base/git-show-branch --merge-base: Documentation and test
authorMichael J Gruber <git@drmicha.warpmail.net>
Wed, 5 Aug 2009 07:59:20 +0000 (09:59 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Aug 2009 17:29:37 +0000 (10:29 -0700)
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 <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-merge-base.txt
Documentation/git-show-branch.txt
builtin-show-branch.c
t/t6010-merge-base.sh

index 00e400353c5bfe1d6f4a75b5bf2dee9d7eca21bc..ce5b369985c254ec5d986aa3dd250828cf3cc4cb 100644 (file)
@@ -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::
index 2c78c25713c108502b45bdf8d512efe22698a584..734336119c6b1f7ea8241f0404eaa3ba2ae10f69 100644 (file)
@@ -82,9 +82,11 @@ OPTIONS
        Synonym to `--more=-1`
 
 --merge-base::
-       Instead of showing the commit list, just act like the
-       'git-merge-base -a' command, except that it can accept
-       more than two heads.
+       Instead of showing the commit list, determine possible
+       merge bases for the specified commits. All merge bases
+       will be contained in all specified commits. This is
+       different from how linkgit:git-merge-base[1] handles
+       the case of three or more commits.
 
 --independent::
        Among the <reference>s given, display only the ones that
index 03bdea686321be4785ba9d4fe0de3fe92449fdab..3510a86e38d2821880060d4faa554c016a9f95e2 100644 (file)
@@ -665,7 +665,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                OPT_BOOLEAN(0, "sha1-name", &sha1_name,
                            "name commits with their object names"),
                OPT_BOOLEAN(0, "merge-base", &merge_base,
-                           "act like git merge-base -a"),
+                           "show possible merge bases"),
                OPT_BOOLEAN(0, "independent", &independent,
                            "show refs unreachable from any other ref"),
                OPT_BOOLEAN(0, "topo-order", &lifo,
index 79124ec761a90fd0e2f028b4566fd21947ba5490..0144d9e858d2d8bf1720331c52f1809ed36e81b0 100755 (executable)
@@ -149,6 +149,12 @@ test_expect_success 'merge-base A B C' '
        test "$MM1" = "$MB"
 '
 
+test_expect_success 'merge-base A B C using show-branch' '
+       MB=$(git show-branch --merge-base MMA MMB MMC) &&
+       MMR=$(git rev-parse --verify MMR) &&
+       test "$MMR" = "$MB"
+'
+
 test_expect_success 'criss-cross merge-base for octopus-step (setup)' '
        git reset --hard MMR &&
        test_tick && git commit --allow-empty -m 1 && git tag CC1 &&