X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fgit.git;a=blobdiff_plain;f=commit-reach.c;h=176121766335b8dcdcad0db76591407cf9db7a60;hp=4ca7e706a18ecf3c6cf862966b9d2f81d02bc964;hb=a08a83db2bf27f015bec9a435f6d73e223c21c5e;hpb=80b806f1a8a5a51fe2cab52ecfc399142e677ef4 diff --git a/commit-reach.c b/commit-reach.c index 4ca7e706a1..1761217663 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -283,7 +283,9 @@ struct commit_list *repo_get_merge_bases(struct repository *r, /* * Is "commit" a descendant of one of the elements on the "with_commit" list? */ -int is_descendant_of(struct commit *commit, struct commit_list *with_commit) +static int repo_is_descendant_of(struct repository *r, + struct commit *commit, + struct commit_list *with_commit) { if (!with_commit) return 1; @@ -301,13 +303,18 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit) other = with_commit->item; with_commit = with_commit->next; - if (in_merge_bases(other, commit)) + if (repo_in_merge_bases_many(r, other, 1, &commit)) return 1; } return 0; } } +int is_descendant_of(struct commit *commit, struct commit_list *with_commit) +{ + return repo_is_descendant_of(the_repository, commit, with_commit); +} + /* * Is "commit" an ancestor of one of the "references"? */ @@ -348,7 +355,15 @@ int repo_in_merge_bases(struct repository *r, struct commit *commit, struct commit *reference) { - return repo_in_merge_bases_many(r, commit, 1, &reference); + int res; + struct commit_list *list = NULL; + struct commit_list **next = &list; + + next = commit_list_append(commit, next); + res = repo_is_descendant_of(r, reference, list); + free_commit_list(list); + + return res; } struct commit_list *reduce_heads(struct commit_list *heads) @@ -396,6 +411,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) struct object *o; struct commit *old_commit, *new_commit; struct commit_list *old_commit_list = NULL; + int ret; /* * Both new_commit and old_commit must be commit-ish and new_commit is descendant of @@ -417,7 +433,9 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) return 0; commit_list_insert(old_commit, &old_commit_list); - return is_descendant_of(new_commit, old_commit_list); + ret = is_descendant_of(new_commit, old_commit_list); + free_commit_list(old_commit_list); + return ret; } /*