{"thread":{"id":"6301","subject":"[PATCH 1/6] Allow in_merge_bases() to take more than one reference commits.","startedAt":"2007-01-09T10:41:26Z","lastAt":"2007-01-09T10:41:26Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"31226","messageId":"7vzm8so52h.fsf@assigned-by-dhcp.cox.net","threadId":"6301","inReplyTo":null,"subject":"[PATCH 1/6] Allow in_merge_bases() to take more than one reference commits.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-09T10:41:26Z","receivedAt":"2007-01-09T10:41:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The internal function in_merge_bases(A, B) is used to make sure\nthat commit A is an ancestor of commit B.  This changes the\nsignature of it to take an array of B's and updates its current\ncallers.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n builtin-branch.c |    2 +-\n builtin-reflog.c |    4 ++--\n commit.c         |    9 ++++++---\n commit.h         |    2 +-\n 4 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex c760e18..daca603 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -134,7 +134,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)\n \t\t */\n \n \t\tif (!force &&\n-\t\t    !in_merge_bases(rev, head_rev)) {\n+\t\t    !in_merge_bases(rev, &head_rev, 1)) {\n \t\t\terror(\"The branch '%s' is not a strict subset of \"\n \t\t\t\t\"your current HEAD.\\n\"\n \t\t\t\t\"If you are sure you want to delete it, \"\ndiff --git a/builtin-reflog.c b/builtin-reflog.c\nindex a967117..fb37984 100644\n--- a/builtin-reflog.c\n+++ b/builtin-reflog.c\n@@ -217,8 +217,8 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n \n \tif ((timestamp < cb->cmd->expire_unreachable) &&\n \t    (!cb->ref_commit ||\n-\t     (old && !in_merge_bases(old, cb->ref_commit)) ||\n-\t     (new && !in_merge_bases(new, cb->ref_commit))))\n+\t     (old && !in_merge_bases(old, &cb->ref_commit, 1)) ||\n+\t     (new && !in_merge_bases(new, &cb->ref_commit, 1))))\n \t\tgoto prune;\n \n \tif (cb->newlog)\ndiff --git a/commit.c b/commit.c\nindex 496d37a..aa14c5a 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -1158,14 +1158,17 @@ struct commit_list *get_merge_bases(struct commit *one,\n \treturn result;\n }\n \n-int in_merge_bases(struct commit *rev1, struct commit *rev2)\n+int in_merge_bases(struct commit *commit, struct commit **reference, int num)\n {\n \tstruct commit_list *bases, *b;\n \tint ret = 0;\n \n-\tbases = get_merge_bases(rev1, rev2, 1);\n+\tif (num == 1)\n+\t\tbases = get_merge_bases(commit, *reference, 1);\n+\telse\n+\t\tdie(\"not yet\");\n \tfor (b = bases; b; b = b->next) {\n-\t\tif (!hashcmp(rev1->object.sha1, b->item->object.sha1)) {\n+\t\tif (!hashcmp(commit->object.sha1, b->item->object.sha1)) {\n \t\t\tret = 1;\n \t\t\tbreak;\n \t\t}\ndiff --git a/commit.h b/commit.h\nindex 936f8fc..b8e6e18 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -114,5 +114,5 @@ extern int is_repository_shallow();\n extern struct commit_list *get_shallow_commits(struct object_array *heads,\n \t\tint depth, int shallow_flag, int not_shallow_flag);\n \n-int in_merge_bases(struct commit *rev1, struct commit *rev2);\n+int in_merge_bases(struct commit *, struct commit **, int);\n #endif /* COMMIT_H */\n-- \n1.4.4.4.g564d\n"}]}