mirror of
https://github.com/git/git.git
synced 2024-05-09 11:26:09 +02:00
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>
This commit is contained in:
parent
ed03a58b65
commit
597b2c39af
11
commit.c
11
commit.c
|
@ -544,6 +544,17 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list *
|
||||||
return new_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 commit_list_count(const struct commit_list *l)
|
||||||
{
|
{
|
||||||
unsigned c = 0;
|
unsigned c = 0;
|
||||||
|
|
2
commit.h
2
commit.h
|
@ -167,6 +167,8 @@ int find_commit_subject(const char *commit_buffer, const char **subject);
|
||||||
|
|
||||||
struct commit_list *commit_list_insert(struct commit *item,
|
struct commit_list *commit_list_insert(struct commit *item,
|
||||||
struct commit_list **list);
|
struct commit_list **list);
|
||||||
|
int commit_list_contains(struct commit *item,
|
||||||
|
struct commit_list *list);
|
||||||
struct commit_list **commit_list_append(struct commit *commit,
|
struct commit_list **commit_list_append(struct commit *commit,
|
||||||
struct commit_list **next);
|
struct commit_list **next);
|
||||||
unsigned commit_list_count(const struct commit_list *l);
|
unsigned commit_list_count(const struct commit_list *l);
|
||||||
|
|
Loading…
Reference in New Issue