summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-12-08 22:04:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-08 22:48:16 (GMT)
commit597b2c39af9ee65496591448715588b711e91947 (patch)
treeb280b25ab8ae1e1f1460cd7770b543dd2ecdf6c3 /commit.c
parented03a58b655f661ef6f9efd8816efe0c8cf07fa0 (diff)
downloadgit-597b2c39af9ee65496591448715588b711e91947.zip
git-597b2c39af9ee65496591448715588b711e91947.tar.gz
git-597b2c39af9ee65496591448715588b711e91947.tar.bz2
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 <dstolee@microsoft.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index fe1fa3d..9a785bf 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;