Skip to content

Commit f621a84

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 995bdc7 commit f621a84

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

Documentation/git-merge-base.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ commits on the command line. As the most common special case, specifying only
2727
two commits on the command line means computing the merge base between
2828
the given two commits.
2929

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+
3034
OPTIONS
3135
-------
3236
-a::

Documentation/git-show-branch.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ OPTIONS
8282
Synonym to `--more=-1`
8383

8484
--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.
8890

8991
--independent::
9092
Among the <reference>s given, display only the ones that

builtin-show-branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
665665
OPT_BOOLEAN(0, "sha1-name", &sha1_name,
666666
"name commits with their object names"),
667667
OPT_BOOLEAN(0, "merge-base", &merge_base,
668-
"act like git merge-base -a"),
668+
"show possible merge bases"),
669669
OPT_BOOLEAN(0, "independent", &independent,
670670
"show refs unreachable from any other ref"),
671671
OPT_BOOLEAN(0, "topo-order", &lifo,

t/t6010-merge-base.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ test_expect_success 'merge-base A B C' '
149149
test "$MM1" = "$MB"
150150
'
151151

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+
152158
test_expect_success 'criss-cross merge-base for octopus-step (setup)' '
153159
git reset --hard MMR &&
154160
test_tick && git commit --allow-empty -m 1 && git tag CC1 &&

0 commit comments

Comments
 (0)