in_merge_bases(): use paint_down_to_common()

With paint_down_to_common(), we can tell if "commit" is reachable from "reference" by simply looking at its object flag, instead of iterating over the merge bases. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 30, 2012 at 15:04 UTC 6440fdbab430bc10fdac37e86ae25607c93d3903
1 file changed +7 -10
commit.c
+7 -10
@@ -786,20 +786,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
786 */
787 int in_merge_bases(struct commit *commit, struct commit *reference)
788 {
789 - struct commit_list *bases, *b;
789 + struct commit_list *bases;
790 int ret = 0;
791
792 - bases = merge_bases_many(commit, 1, &reference);
792 + if (parse_commit(commit) || parse_commit(reference))
793 + return ret;
794 +
795 + bases = paint_down_to_common(commit, 1, &reference);
796 + if (commit->object.flags & PARENT2)
797 + ret = 1;
798 clear_commit_marks(commit, all_flags);
799 clear_commit_marks(reference, all_flags);
795 -
796 - for (b = bases; b; b = b->next) {
797 - if (!hashcmp(commit->object.sha1, b->item->object.sha1)) {
798 - ret = 1;
799 - break;
800 - }
801 - }
802 -
800 free_commit_list(bases);
801 return ret;
802 }