@matheusbsbs / matheus-bagliano / commits / 5240c9d75d
Fork 0

Introduce get_octopus_merge_bases() in commit.c

This is like get_merge_bases() but it works for multiple heads, like show-branch --merge-base. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Miklos Vajna committed Jun 27, 2008 at 18:22 UTC 5240c9d75d8e1b747da427ba6320432d3201168a
2 files changed +28
commit.c
+27
@@ -600,6 +600,33 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two)
600 return result;
601 }
602
603 +struct commit_list *get_octopus_merge_bases(struct commit_list *in)
604 +{
605 + struct commit_list *i, *j, *k, *ret = NULL;
606 + struct commit_list **pptr = &ret;
607 +
608 + for (i = in; i; i = i->next) {
609 + if (!ret)
610 + pptr = &commit_list_insert(i->item, pptr)->next;
611 + else {
612 + struct commit_list *new = NULL, *end = NULL;
613 +
614 + for (j = ret; j; j = j->next) {
615 + struct commit_list *bases;
616 + bases = get_merge_bases(i->item, j->item, 1);
617 + if (!new)
618 + new = bases;
619 + else
620 + end->next = bases;
621 + for (k = bases; k; k = k->next)
622 + end = k;
623 + }
624 + ret = new;
625 + }
626 + }
627 + return ret;
628 +}
629 +
630 struct commit_list *get_merge_bases(struct commit *one,
631 struct commit *two, int cleanup)
632 {
commit.h
+1
@@ -121,6 +121,7 @@ int read_graft_file(const char *graft_file);
121 struct commit_graft *lookup_commit_graft(const unsigned char *sha1);
122
123 extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup);
124 +extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);
125
126 extern int register_shallow(const unsigned char *sha1);
127 extern int unregister_shallow(const unsigned char *sha1);