This is like get_merge_bases() but it works for multiple heads. Internally it uses merge_bases_many() but it has the ability to clear commit marks like get_merge_bases(). Signed-off-by: Miklos Vajna <vmiklos@xxxxxxxxxxxxxx> --- On Thu, Jun 05, 2008 at 10:53:59PM -0700, Junio C Hamano <gitster@xxxxxxxxx> wrote: > Something like this might be enough to get us started. Instead of > finding > out the merge bases between two commits, "one" and "two", this would > find > merge base between "one" and a commit that would be a merge across all > the > "two"s. To apply it to the above example, you would give "C" as > "one", > and "A" and "B" as "twos" to it, to compute "2". Here is what I pushed to my working branch, on top of your patch. BTW: How should I credit your patch? Add a Signed-off-by? If I make you the author I don't know how send-email handles the situation. Thanks. commit.c | 17 +++++++++++++++++ commit.h | 1 + 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/commit.c b/commit.c index 1dba717..685a144 100644 --- a/commit.c +++ b/commit.c @@ -618,6 +618,23 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two) return merge_bases_many(one, 1, &two); } +struct commit_list *get_octopus_merge_bases(struct commit_list *in, int cleanup) +{ + struct commit *head = in->item; + int n = 0; + struct commit **commits = xmalloc(n*sizeof(struct commit *)); + struct commit_list *ret, *i; + + for(i = in; i; i = i->next, n++) + commits[n] = i->item; + ret = merge_bases_many(head, n, commits); + free(commits); + if (cleanup) + for(i = in; i; i = i->next) + clear_commit_marks(i->item, all_flags); + return ret; +} + struct commit_list *get_merge_bases(struct commit *one, struct commit *two, int cleanup) { diff --git a/commit.h b/commit.h index 7f8c5ee..ca858ed 100644 --- a/commit.h +++ b/commit.h @@ -121,6 +121,7 @@ int read_graft_file(const char *graft_file); struct commit_graft *lookup_commit_graft(const unsigned char *sha1); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup); +extern struct commit_list *get_octopus_merge_bases(struct commit_list *in, int cleanup); extern int register_shallow(const unsigned char *sha1); extern int unregister_shallow(const unsigned char *sha1); -- 1.5.6.rc0.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html