Skip to content

Commit 0258ed1

Browse files
committed
Merge branch 'cb/is-descendant-of'
Code clean-up. * cb/is-descendant-of: commit-reach: avoid is_descendant_of() shim
2 parents 5c61d10 + c1ea625 commit 0258ed1

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

builtin/pull.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
10251025
commit_list_insert(head, &list);
10261026
merge_head = lookup_commit_reference(the_repository,
10271027
&merge_heads.oid[0]);
1028-
if (is_descendant_of(merge_head, list)) {
1028+
if (repo_is_descendant_of(the_repository,
1029+
merge_head, list)) {
10291030
/* we can fast-forward this without invoking rebase */
10301031
opt_ff = "--ff-only";
10311032
ran_ff = 1;

commit-reach.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ struct commit_list *repo_get_merge_bases(struct repository *r,
286286
/*
287287
* Is "commit" a descendant of one of the elements on the "with_commit" list?
288288
*/
289-
static int repo_is_descendant_of(struct repository *r,
290-
struct commit *commit,
291-
struct commit_list *with_commit)
289+
int repo_is_descendant_of(struct repository *r,
290+
struct commit *commit,
291+
struct commit_list *with_commit)
292292
{
293293
if (!with_commit)
294294
return 1;
@@ -313,11 +313,6 @@ static int repo_is_descendant_of(struct repository *r,
313313
}
314314
}
315315

316-
int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
317-
{
318-
return repo_is_descendant_of(the_repository, commit, with_commit);
319-
}
320-
321316
/*
322317
* Is "commit" an ancestor of one of the "references"?
323318
*/
@@ -439,7 +434,8 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
439434
return 0;
440435

441436
commit_list_insert(old_commit, &old_commit_list);
442-
ret = is_descendant_of(new_commit, old_commit_list);
437+
ret = repo_is_descendant_of(the_repository,
438+
new_commit, old_commit_list);
443439
free_commit_list(old_commit_list);
444440
return ret;
445441
}
@@ -562,7 +558,7 @@ int commit_contains(struct ref_filter *filter, struct commit *commit,
562558
{
563559
if (filter->with_commit_tag_algo)
564560
return contains_tag_algo(commit, list, cache) == CONTAINS_YES;
565-
return is_descendant_of(commit, list);
561+
return repo_is_descendant_of(the_repository, commit, list);
566562
}
567563

568564
static int compare_commits_by_gen(const void *_a, const void *_b)

commit-reach.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ struct commit_list *repo_get_merge_bases_many_dirty(struct repository *r,
2727

2828
struct commit_list *get_octopus_merge_bases(struct commit_list *in);
2929

30-
int is_descendant_of(struct commit *commit, struct commit_list *with_commit);
30+
int repo_is_descendant_of(struct repository *r,
31+
struct commit *commit,
32+
struct commit_list *with_commit);
3133
int repo_in_merge_bases(struct repository *r,
3234
struct commit *commit,
3335
struct commit *reference);

t/helper/test-reach.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int cmd__reach(int ac, const char **av)
108108
else if (!strcmp(av[1], "in_merge_bases"))
109109
printf("%s(A,B):%d\n", av[1], in_merge_bases(A, B));
110110
else if (!strcmp(av[1], "is_descendant_of"))
111-
printf("%s(A,X):%d\n", av[1], is_descendant_of(A, X));
111+
printf("%s(A,X):%d\n", av[1], repo_is_descendant_of(r, A, X));
112112
else if (!strcmp(av[1], "get_merge_bases_many")) {
113113
struct commit_list *list = get_merge_bases_many(A, X_nr, X_array);
114114
printf("%s(A,X):\n", av[1]);

0 commit comments

Comments
 (0)