summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-07-06 22:09:15 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-07-06 22:09:16 -0700
commit0258ed1e08e7973f1d6829db8d33109851067a91 (patch)
treec94e74d689f3b1ab05cf3a14392016795506d899
parentMerge branch 'mk/pb-pretty-email-without-domain-part-fix' (diff)
parentcommit-reach: avoid is_descendant_of() shim (diff)
downloadtgif-0258ed1e08e7973f1d6829db8d33109851067a91.tar.xz
Merge branch 'cb/is-descendant-of'
Code clean-up. * cb/is-descendant-of: commit-reach: avoid is_descendant_of() shim
-rw-r--r--builtin/pull.c3
-rw-r--r--commit-reach.c16
-rw-r--r--commit-reach.h4
-rw-r--r--t/helper/test-reach.c2
4 files changed, 12 insertions, 13 deletions
diff --git a/builtin/pull.c b/builtin/pull.c
index 8e6572d305..8159c5d7c9 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -1025,7 +1025,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
commit_list_insert(head, &list);
merge_head = lookup_commit_reference(the_repository,
&merge_heads.oid[0]);
- if (is_descendant_of(merge_head, list)) {
+ if (repo_is_descendant_of(the_repository,
+ merge_head, list)) {
/* we can fast-forward this without invoking rebase */
opt_ff = "--ff-only";
ran_ff = 1;
diff --git a/commit-reach.c b/commit-reach.c
index a7a0b87263..efd5925cbb 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -286,9 +286,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?
*/
-static int repo_is_descendant_of(struct repository *r,
- struct commit *commit,
- struct commit_list *with_commit)
+int repo_is_descendant_of(struct repository *r,
+ struct commit *commit,
+ struct commit_list *with_commit)
{
if (!with_commit)
return 1;
@@ -313,11 +313,6 @@ static int repo_is_descendant_of(struct repository *r,
}
}
-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"?
*/
@@ -439,7 +434,8 @@ 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);
- ret = is_descendant_of(new_commit, old_commit_list);
+ ret = repo_is_descendant_of(the_repository,
+ new_commit, old_commit_list);
free_commit_list(old_commit_list);
return ret;
}
@@ -562,7 +558,7 @@ int commit_contains(struct ref_filter *filter, struct commit *commit,
{
if (filter->with_commit_tag_algo)
return contains_tag_algo(commit, list, cache) == CONTAINS_YES;
- return is_descendant_of(commit, list);
+ return repo_is_descendant_of(the_repository, commit, list);
}
static int compare_commits_by_gen(const void *_a, const void *_b)
diff --git a/commit-reach.h b/commit-reach.h
index 99a43e8b64..b49ad71a31 100644
--- a/commit-reach.h
+++ b/commit-reach.h
@@ -27,7 +27,9 @@ struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
struct commit_list *get_octopus_merge_bases(struct commit_list *in);
-int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
+int repo_is_descendant_of(struct repository *r,
+ struct commit *commit,
+ struct commit_list *with_commit);
int repo_in_merge_bases(struct repository *r,
struct commit *commit,
struct commit *reference);
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index ccf837cb33..14a3655442 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -108,7 +108,7 @@ int cmd__reach(int ac, const char **av)
else if (!strcmp(av[1], "in_merge_bases"))
printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));
else if (!strcmp(av[1], "is_descendant_of"))
- printf("%s(A,X):%d\n", av[1], is_descendant_of(A, X));
+ printf("%s(A,X):%d\n", av[1], repo_is_descendant_of(r, A, X));
else if (!strcmp(av[1], "get_merge_bases_many")) {
struct commit_list *list = get_merge_bases_many(A, X_nr, X_array);
printf("%s(A,X):\n", av[1]);