Browse Source

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>
maint
Junio C Hamano 13 years ago
parent
commit
6440fdbab4
  1. 17
      commit.c

17
commit.c

@ -786,20 +786,17 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
*/ */
int in_merge_bases(struct commit *commit, struct commit *reference) int in_merge_bases(struct commit *commit, struct commit *reference)
{ {
struct commit_list *bases, *b; struct commit_list *bases;
int ret = 0; int ret = 0;


bases = merge_bases_many(commit, 1, &reference); if (parse_commit(commit) || parse_commit(reference))
clear_commit_marks(commit, all_flags); return ret;
clear_commit_marks(reference, all_flags);


for (b = bases; b; b = b->next) { bases = paint_down_to_common(commit, 1, &reference);
if (!hashcmp(commit->object.sha1, b->item->object.sha1)) { if (commit->object.flags & PARENT2)
ret = 1; ret = 1;
break; clear_commit_marks(commit, all_flags);
} clear_commit_marks(reference, all_flags);
}

free_commit_list(bases); free_commit_list(bases);
return ret; return ret;
} }

Loading…
Cancel
Save