diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-08-30 15:04:13 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-08-30 17:25:57 -0700 |
commit | 6440fdbab430bc10fdac37e86ae25607c93d3903 (patch) | |
tree | d4b9895656c446c0d8bc6bc4cba910f33056a6d9 /commit.c | |
parent | da1f515641f4853a6b7c4710392796ed08efaa6f (diff) | |
download | git-6440fdbab430bc10fdac37e86ae25607c93d3903.tar.gz |
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>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -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) { - struct commit_list *bases, *b; + struct commit_list *bases; int ret = 0; - bases = merge_bases_many(commit, 1, &reference); + if (parse_commit(commit) || parse_commit(reference)) + return ret; + + bases = paint_down_to_common(commit, 1, &reference); + if (commit->object.flags & PARENT2) + ret = 1; clear_commit_marks(commit, all_flags); clear_commit_marks(reference, all_flags); - - for (b = bases; b; b = b->next) { - if (!hashcmp(commit->object.sha1, b->item->object.sha1)) { - ret = 1; - break; - } - } - free_commit_list(bases); return ret; } |