From 597b2c39af9ee65496591448715588b711e91947 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Tue, 8 Dec 2020 17:04:13 -0500 Subject: commit: implement commit_list_contains() It can be helpful to check if a commit_list contains a commit. Use pointer equality, assuming lookup_commit() was used. Signed-off-by: Derrick Stolee Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- commit.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'commit.c') diff --git a/commit.c b/commit.c index fe1fa3dc41..9a785bf906 100644 --- a/commit.c +++ b/commit.c @@ -544,6 +544,17 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list * return new_list; } +int commit_list_contains(struct commit *item, struct commit_list *list) +{ + while (list) { + if (list->item == item) + return 1; + list = list->next; + } + + return 0; +} + unsigned commit_list_count(const struct commit_list *l) { unsigned c = 0; -- cgit v1.2.3