Move commit_list_count() to commit.c

This function is useful outside builtin-merge-recursive, for example in
builtin-merge.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Miklos Vajna 2008-06-27 18:21:55 +02:00 committed by Junio C Hamano
parent 0989fe9623
commit 653194758e
3 changed files with 9 additions and 8 deletions

View File

@ -42,14 +42,6 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two)
* - *(int *)commit->object.sha1 set to the virtual id. * - *(int *)commit->object.sha1 set to the virtual id.
*/ */
static unsigned commit_list_count(const struct commit_list *l)
{
unsigned c = 0;
for (; l; l = l->next )
c++;
return c;
}
static struct commit *make_virtual_commit(struct tree *tree, const char *comment) static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
{ {
struct commit *commit = xcalloc(1, sizeof(struct commit)); struct commit *commit = xcalloc(1, sizeof(struct commit));

View File

@ -325,6 +325,14 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list *
return new_list; return new_list;
} }
unsigned commit_list_count(const struct commit_list *l)
{
unsigned c = 0;
for (; l; l = l->next )
c++;
return c;
}
void free_commit_list(struct commit_list *list) void free_commit_list(struct commit_list *list)
{ {
while (list) { while (list) {

View File

@ -41,6 +41,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
int parse_commit(struct commit *item); int parse_commit(struct commit *item);
struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p); struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
unsigned commit_list_count(const struct commit_list *l);
struct commit_list * insert_by_date(struct commit *item, struct commit_list **list); struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
void free_commit_list(struct commit_list *list); void free_commit_list(struct commit_list *list);