{"thread":{"id":"20397","subject":"[PATCH 0/3] git-merge-base -a vs. git-show-branch --merge-base","startedAt":"2009-08-05T07:59:17Z","lastAt":"2009-08-05T07:59:20Z","messageCount":4,"participants":["Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"119581","messageId":"1249459160-3931-1-git-send-email-git@drmicha.warpmail.net","threadId":"20397","inReplyTo":null,"subject":"[PATCH 0/3] git-merge-base -a vs. git-show-branch --merge-base","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-08-05T07:59:17Z","receivedAt":"2009-08-05T07:59:17Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"The two commands above behave differently when more than two commits are\ngiven. The purpose of this patch series is to correct and improve the\ndocumentation in this regard, and to document the difference in behavior\nwith a test.\n\n1/3 only depicts the DAG of a test which is already present, to make it\neasier for future test writers (such as that of 3/3).\n\n2/3 cleans up the documentation so that man pages and usage strings for\nthose two commands coincide.\n\n3/3 adds a test case and corrects the documentation with regards to\nmerge bases for more than two commits.\n\nMichael J Gruber (3):\n  t6010-merge-base.sh: Depict the octopus test graph\n  git-merge-base/git-show-branch: Cleanup documentation and usage\n  git-merge-base/git-show-branch --merge-base: Documentation and test\n\n Documentation/git-merge-base.txt  |    9 +++++++--\n Documentation/git-show-branch.txt |   13 ++++++++-----\n builtin-merge-base.c              |    2 +-\n builtin-show-branch.c             |    6 +++---\n t/t6010-merge-base.sh             |   18 ++++++++++++++++++\n 5 files changed, 37 insertions(+), 11 deletions(-)\n"},{"id":"119583","messageId":"1249459160-3931-2-git-send-email-git@drmicha.warpmail.net","threadId":"20397","inReplyTo":"1249459160-3931-1-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 1/3] t6010-merge-base.sh: Depict the octopus test graph","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-08-05T07:59:18Z","receivedAt":"2009-08-05T07:59:18Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"...so that it is easier to reuse it for other tests.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t6010-merge-base.sh |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh\nindex 04e4b7c..79124ec 100755\n--- a/t/t6010-merge-base.sh\n+++ b/t/t6010-merge-base.sh\n@@ -110,6 +110,18 @@ test_expect_success 'compute merge-base (all)' \\\n \n # Another set to demonstrate base between one commit and a merge\n # in the documentation.\n+#\n+# * C (MMC) * B (MMB) * A  (MMA)\n+# * o       * o       * o\n+# * o       * o       * o\n+# * o       * o       * o\n+# * o       | _______/\n+# |         |/\n+# |         * 1 (MM1)\n+# | _______/\n+# |/\n+# * root (MMR)\n+\n \n test_expect_success 'merge-base for octopus-step (setup)' '\n \ttest_tick && git commit --allow-empty -m root && git tag MMR &&\n-- \n1.6.4.70.g9c084\n"},{"id":"119582","messageId":"1249459160-3931-3-git-send-email-git@drmicha.warpmail.net","threadId":"20397","inReplyTo":"1249459160-3931-2-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 2/3] git-merge-base/git-show-branch: Cleanup documentation and usage","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-08-05T07:59:19Z","receivedAt":"2009-08-05T07:59:19Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Make sure that usage strings and documentation coincide with each other\nand with the actual code.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nAlso does one 's/git-/git /'.\n\n Documentation/git-merge-base.txt  |    5 +++--\n Documentation/git-show-branch.txt |    5 +++--\n builtin-merge-base.c              |    2 +-\n builtin-show-branch.c             |    4 ++--\n 4 files changed, 9 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt\nindex 767486c..00e4003 100644\n--- a/Documentation/git-merge-base.txt\n+++ b/Documentation/git-merge-base.txt\n@@ -8,12 +8,12 @@ git-merge-base - Find as good common ancestors as possible for a merge\n \n SYNOPSIS\n --------\n-'git merge-base' [--all] <commit> <commit>...\n+'git merge-base' [-a|--all] <commit> <commit>...\n \n DESCRIPTION\n -----------\n \n-'git-merge-base' finds best common ancestor(s) between two commits to use\n+'git merge-base' finds best common ancestor(s) between two commits to use\n in a three-way merge.  One common ancestor is 'better' than another common\n ancestor if the latter is an ancestor of the former.  A common ancestor\n that does not have any better common ancestor is a 'best common\n@@ -29,6 +29,7 @@ the given two commits.\n \n OPTIONS\n -------\n+-a::\n --all::\n \tOutput all merge bases for the commits, instead of just one.\n \ndiff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt\nindex 89ec536..2c78c25 100644\n--- a/Documentation/git-show-branch.txt\n+++ b/Documentation/git-show-branch.txt\n@@ -8,11 +8,12 @@ git-show-branch - Show branches and their commits\n SYNOPSIS\n --------\n [verse]\n-'git show-branch' [--all] [--remotes] [--topo-order | --date-order]\n-\t\t[--current] [--color | --no-color]\n+'git show-branch' [-a|--all] [-r|--remotes] [--topo-order | --date-order]\n+\t\t[--current] [--color | --no-color] [--sparse]\n \t\t[--more=<n> | --list | --independent | --merge-base]\n \t\t[--no-name | --sha1-name] [--topics]\n \t\t[<rev> | <glob>]...\n+\n 'git show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]\n \n DESCRIPTION\ndiff --git a/builtin-merge-base.c b/builtin-merge-base.c\nindex a6ec2f7..54e7ec2 100644\n--- a/builtin-merge-base.c\n+++ b/builtin-merge-base.c\n@@ -23,7 +23,7 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)\n }\n \n static const char * const merge_base_usage[] = {\n-\t\"git merge-base [--all] <commit-id> <commit-id>...\",\n+\t\"git merge-base [-a|--all] <commit> <commit>...\",\n \tNULL\n };\n \ndiff --git a/builtin-show-branch.c b/builtin-show-branch.c\nindex 01bea3b..03bdea6 100644\n--- a/builtin-show-branch.c\n+++ b/builtin-show-branch.c\n@@ -6,8 +6,8 @@\n #include \"parse-options.h\"\n \n static const char* show_branch_usage[] = {\n-    \"git show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base] [--topics] [--color] [<refs>...]\",\n-    \"--reflog[=n[,b]] [--list] [--color] <branch>\",\n+    \"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>]...\",\n+    \"git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]\",\n     NULL\n };\n \n-- \n1.6.4.70.g9c084\n"},{"id":"119584","messageId":"1249459160-3931-4-git-send-email-git@drmicha.warpmail.net","threadId":"20397","inReplyTo":"1249459160-3931-3-git-send-email-git@drmicha.warpmail.net","subject":"[PATCH 3/3] git-merge-base/git-show-branch --merge-base: Documentation and test","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-08-05T07:59:20Z","receivedAt":"2009-08-05T07:59:20Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, the documentation suggests that 'git merge-base -a' and 'git\nshow-branch --merge-base' are equivalent (in fact it claims that the\nformer cannot handle more than two revs).\n\nAlas, the handling of more than two revs is very different. Document\nthis by tests and correct the documentation to reflect this.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-merge-base.txt  |    4 ++++\n Documentation/git-show-branch.txt |    8 +++++---\n builtin-show-branch.c             |    2 +-\n t/t6010-merge-base.sh             |    6 ++++++\n 4 files changed, 16 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt\nindex 00e4003..ce5b369 100644\n--- a/Documentation/git-merge-base.txt\n+++ b/Documentation/git-merge-base.txt\n@@ -27,6 +27,10 @@ commits on the command line.  As the most common special case, specifying only\n two commits on the command line means computing the merge base between\n the given two commits.\n \n+As a consequence, the 'merge base' is not necessarily contained in each of the\n+commit arguments if more than two commits are specified. This is different\n+from linkgit:git-show-branch[1] when used with the `--merge-base` option.\n+\n OPTIONS\n -------\n -a::\ndiff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt\nindex 2c78c25..7343361 100644\n--- a/Documentation/git-show-branch.txt\n+++ b/Documentation/git-show-branch.txt\n@@ -82,9 +82,11 @@ OPTIONS\n \tSynonym to `--more=-1`\n \n --merge-base::\n-\tInstead of showing the commit list, just act like the\n-\t'git-merge-base -a' command, except that it can accept\n-\tmore than two heads.\n+\tInstead of showing the commit list, determine possible\n+\tmerge bases for the specified commits. All merge bases\n+\twill be contained in all specified commits. This is\n+\tdifferent from how linkgit:git-merge-base[1] handles\n+\tthe case of three or more commits.\n \n --independent::\n \tAmong the <reference>s given, display only the ones that\ndiff --git a/builtin-show-branch.c b/builtin-show-branch.c\nindex 03bdea6..3510a86 100644\n--- a/builtin-show-branch.c\n+++ b/builtin-show-branch.c\n@@ -665,7 +665,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\tOPT_BOOLEAN(0, \"sha1-name\", &sha1_name,\n \t\t\t    \"name commits with their object names\"),\n \t\tOPT_BOOLEAN(0, \"merge-base\", &merge_base,\n-\t\t\t    \"act like git merge-base -a\"),\n+\t\t\t    \"show possible merge bases\"),\n \t\tOPT_BOOLEAN(0, \"independent\", &independent,\n \t\t\t    \"show refs unreachable from any other ref\"),\n \t\tOPT_BOOLEAN(0, \"topo-order\", &lifo,\ndiff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh\nindex 79124ec..0144d9e 100755\n--- a/t/t6010-merge-base.sh\n+++ b/t/t6010-merge-base.sh\n@@ -149,6 +149,12 @@ test_expect_success 'merge-base A B C' '\n \ttest \"$MM1\" = \"$MB\"\n '\n \n+test_expect_success 'merge-base A B C using show-branch' '\n+\tMB=$(git show-branch --merge-base MMA MMB MMC) &&\n+\tMMR=$(git rev-parse --verify MMR) &&\n+\ttest \"$MMR\" = \"$MB\"\n+'\n+\n test_expect_success 'criss-cross merge-base for octopus-step (setup)' '\n \tgit reset --hard MMR &&\n \ttest_tick && git commit --allow-empty -m 1 && git tag CC1 &&\n-- \n1.6.4.70.g9c084\n"}]}