* [PATCH 0/3] git-merge-base -a vs. git-show-branch --merge-base @ 2009-08-05 7:59 Michael J Gruber 2009-08-05 7:59 ` [PATCH 1/3] t6010-merge-base.sh: Depict the octopus test graph Michael J Gruber 0 siblings, 1 reply; 4+ messages in thread From: Michael J Gruber @ 2009-08-05 7:59 UTC (permalink / raw) To: git; +Cc: Junio C Hamano The two commands above behave differently when more than two commits are given. The purpose of this patch series is to correct and improve the documentation in this regard, and to document the difference in behavior with a test. 1/3 only depicts the DAG of a test which is already present, to make it easier for future test writers (such as that of 3/3). 2/3 cleans up the documentation so that man pages and usage strings for those two commands coincide. 3/3 adds a test case and corrects the documentation with regards to merge bases for more than two commits. Michael J Gruber (3): t6010-merge-base.sh: Depict the octopus test graph git-merge-base/git-show-branch: Cleanup documentation and usage git-merge-base/git-show-branch --merge-base: Documentation and test Documentation/git-merge-base.txt | 9 +++++++-- Documentation/git-show-branch.txt | 13 ++++++++----- builtin-merge-base.c | 2 +- builtin-show-branch.c | 6 +++--- t/t6010-merge-base.sh | 18 ++++++++++++++++++ 5 files changed, 37 insertions(+), 11 deletions(-) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] t6010-merge-base.sh: Depict the octopus test graph 2009-08-05 7:59 [PATCH 0/3] git-merge-base -a vs. git-show-branch --merge-base Michael J Gruber @ 2009-08-05 7:59 ` Michael J Gruber 2009-08-05 7:59 ` [PATCH 2/3] git-merge-base/git-show-branch: Cleanup documentation and usage Michael J Gruber 0 siblings, 1 reply; 4+ messages in thread From: Michael J Gruber @ 2009-08-05 7:59 UTC (permalink / raw) To: git; +Cc: Junio C Hamano ...so that it is easier to reuse it for other tests. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> --- t/t6010-merge-base.sh | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh index 04e4b7c..79124ec 100755 --- a/t/t6010-merge-base.sh +++ b/t/t6010-merge-base.sh @@ -110,6 +110,18 @@ test_expect_success 'compute merge-base (all)' \ # Another set to demonstrate base between one commit and a merge # in the documentation. +# +# * C (MMC) * B (MMB) * A (MMA) +# * o * o * o +# * o * o * o +# * o * o * o +# * o | _______/ +# | |/ +# | * 1 (MM1) +# | _______/ +# |/ +# * root (MMR) + test_expect_success 'merge-base for octopus-step (setup)' ' test_tick && git commit --allow-empty -m root && git tag MMR && -- 1.6.4.70.g9c084 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] git-merge-base/git-show-branch: Cleanup documentation and usage 2009-08-05 7:59 ` [PATCH 1/3] t6010-merge-base.sh: Depict the octopus test graph Michael J Gruber @ 2009-08-05 7:59 ` Michael J Gruber 2009-08-05 7:59 ` [PATCH 3/3] git-merge-base/git-show-branch --merge-base: Documentation and test Michael J Gruber 0 siblings, 1 reply; 4+ messages in thread From: Michael J Gruber @ 2009-08-05 7:59 UTC (permalink / raw) To: git; +Cc: Junio C Hamano Make sure that usage strings and documentation coincide with each other and with the actual code. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> --- Also does one 's/git-/git /'. Documentation/git-merge-base.txt | 5 +++-- Documentation/git-show-branch.txt | 5 +++-- builtin-merge-base.c | 2 +- builtin-show-branch.c | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 767486c..00e4003 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] <commit> <commit>... +'git merge-base' [-a|--all] <commit> <commit>... 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. diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index 89ec536..2c78c25 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -8,11 +8,12 @@ git-show-branch - Show branches and their commits SYNOPSIS -------- [verse] -'git show-branch' [--all] [--remotes] [--topo-order | --date-order] - [--current] [--color | --no-color] +'git show-branch' [-a|--all] [-r|--remotes] [--topo-order | --date-order] + [--current] [--color | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [<rev> | <glob>]... + 'git show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>] DESCRIPTION diff --git a/builtin-merge-base.c b/builtin-merge-base.c index a6ec2f7..54e7ec2 100644 --- a/builtin-merge-base.c +++ b/builtin-merge-base.c @@ -23,7 +23,7 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all) } static const char * const merge_base_usage[] = { - "git merge-base [--all] <commit-id> <commit-id>...", + "git merge-base [-a|--all] <commit> <commit>...", NULL }; diff --git a/builtin-show-branch.c b/builtin-show-branch.c index 01bea3b..03bdea6 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -6,8 +6,8 @@ #include "parse-options.h" static const char* show_branch_usage[] = { - "git show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base] [--topics] [--color] [<refs>...]", - "--reflog[=n[,b]] [--list] [--color] <branch>", + "git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [<rev> | <glob>]...", + "git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]", NULL }; -- 1.6.4.70.g9c084 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] git-merge-base/git-show-branch --merge-base: Documentation and test 2009-08-05 7:59 ` [PATCH 2/3] git-merge-base/git-show-branch: Cleanup documentation and usage Michael J Gruber @ 2009-08-05 7:59 ` Michael J Gruber 0 siblings, 0 replies; 4+ messages in thread From: Michael J Gruber @ 2009-08-05 7:59 UTC (permalink / raw) To: git; +Cc: Junio C Hamano 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> --- Documentation/git-merge-base.txt | 4 ++++ Documentation/git-show-branch.txt | 8 +++++--- builtin-show-branch.c | 2 +- t/t6010-merge-base.sh | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt index 00e4003..ce5b369 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:: diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt index 2c78c25..7343361 100644 --- a/Documentation/git-show-branch.txt +++ b/Documentation/git-show-branch.txt @@ -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 diff --git a/builtin-show-branch.c b/builtin-show-branch.c index 03bdea6..3510a86 100644 --- a/builtin-show-branch.c +++ b/builtin-show-branch.c @@ -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, diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh index 79124ec..0144d9e 100755 --- a/t/t6010-merge-base.sh +++ b/t/t6010-merge-base.sh @@ -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 && -- 1.6.4.70.g9c084 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-08-05 7:59 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-08-05 7:59 [PATCH 0/3] git-merge-base -a vs. git-show-branch --merge-base Michael J Gruber 2009-08-05 7:59 ` [PATCH 1/3] t6010-merge-base.sh: Depict the octopus test graph Michael J Gruber 2009-08-05 7:59 ` [PATCH 2/3] git-merge-base/git-show-branch: Cleanup documentation and usage Michael J Gruber 2009-08-05 7:59 ` [PATCH 3/3] git-merge-base/git-show-branch --merge-base: Documentation and test Michael J Gruber
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).