Skip to content

Commit

Permalink
Move commit_list_count() to commit.c
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Miklos Vajna authored and gitster committed Jul 1, 2008
1 parent 0989fe9 commit 6531947
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 0 additions & 8 deletions builtin-merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

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)
{
struct commit *commit = xcalloc(1, sizeof(struct commit));
Expand Down
8 changes: 8 additions & 0 deletions commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_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)
{
while (list) {
Expand Down
1 change: 1 addition & 0 deletions commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
int parse_commit(struct commit *item);

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);

void free_commit_list(struct commit_list *list);
Expand Down

0 comments on commit 6531947

Please sign in to comment.