@matheusbsbs / matheus-bagliano / commits / d91d6fbf26
Fork 0

commit-reach: create repo_is_descendant_of()

The next change will make repo_in_merge_bases() depend on the logic in is_descendant_of(), but we need to make the method independent of the_repository first. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Jun 17, 2020 at 17:24 UTC d91d6fbf26663ab64c453411c2de6cf4ea754246
1 file changed +9 -2
commit-reach.c
+9 -2
@@ -283,7 +283,9 @@ struct commit_list *repo_get_merge_bases(struct repository *r,
283 /*
284 * Is "commit" a descendant of one of the elements on the "with_commit" list?
285 */
286 -int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
286 +static int repo_is_descendant_of(struct repository *r,
287 + struct commit *commit,
288 + struct commit_list *with_commit)
289 {
290 if (!with_commit)
291 return 1;
@@ -301,13 +303,18 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
303
304 other = with_commit->item;
305 with_commit = with_commit->next;
304 - if (in_merge_bases(other, commit))
306 + if (repo_in_merge_bases(r, other, commit))
307 return 1;
308 }
309 return 0;
310 }
311 }
312
313 +int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
314 +{
315 + return repo_is_descendant_of(the_repository, commit, with_commit);
316 +}
317 +
318 /*
319 * Is "commit" an ancestor of one of the "references"?
320 */