@matheusbsbs / matheus-bagliano / commits / f621a8454d
Fork 0

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 <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Aug 5, 2009 at 09:59 UTC f621a8454d19d17fe46e6951b7e3d22bebd92aba
4 files changed +16 -4
Documentation/git-merge-base.txt
+4
@@ -27,6 +27,10 @@ commits on the command line. As the most common special case, specifying only
27 two commits on the command line means computing the merge base between
28 the given two commits.
29
30 +As a consequence, the 'merge base' is not necessarily contained in each of the
31 +commit arguments if more than two commits are specified. This is different
32 +from linkgit:git-show-branch[1] when used with the `--merge-base` option.
33 +
34 OPTIONS
35 -------
36 -a::
Documentation/git-show-branch.txt
+5 -3
@@ -82,9 +82,11 @@ OPTIONS
82 Synonym to `--more=-1`
83
84 --merge-base::
85 - Instead of showing the commit list, just act like the
86 - 'git-merge-base -a' command, except that it can accept
87 - more than two heads.
85 + Instead of showing the commit list, determine possible
86 + merge bases for the specified commits. All merge bases
87 + will be contained in all specified commits. This is
88 + different from how linkgit:git-merge-base[1] handles
89 + the case of three or more commits.
90
91 --independent::
92 Among the <reference>s given, display only the ones that
builtin-show-branch.c
+1 -1
@@ -665,7 +665,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
665 OPT_BOOLEAN(0, "sha1-name", &sha1_name,
666 "name commits with their object names"),
667 OPT_BOOLEAN(0, "merge-base", &merge_base,
668 - "act like git merge-base -a"),
668 + "show possible merge bases"),
669 OPT_BOOLEAN(0, "independent", &independent,
670 "show refs unreachable from any other ref"),
671 OPT_BOOLEAN(0, "topo-order", &lifo,
t/t6010-merge-base.sh
+6
@@ -149,6 +149,12 @@ test_expect_success 'merge-base A B C' '
149 test "$MM1" = "$MB"
150 '
151
152 +test_expect_success 'merge-base A B C using show-branch' '
153 + MB=$(git show-branch --merge-base MMA MMB MMC) &&
154 + MMR=$(git rev-parse --verify MMR) &&
155 + test "$MMR" = "$MB"
156 +'
157 +
158 test_expect_success 'criss-cross merge-base for octopus-step (setup)' '
159 git reset --hard MMR &&
160 test_tick && git commit --allow-empty -m 1 && git tag CC1 &&