summaryrefslogtreecommitdiff
path: root/builtin/for-each-ref.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-07-16 23:52:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-17 20:36:25 (GMT)
commit4bbaa1eb6fb4a520069e53ec5afa977a316a5d36 (patch)
treeceb6d1a97ca5a3a78bb057b889b02fccaa4290fa /builtin/for-each-ref.c
parentcedc61a99804db99f9a658c3cccd5c2786a28501 (diff)
downloadgit-4bbaa1eb6fb4a520069e53ec5afa977a316a5d36.zip
git-4bbaa1eb6fb4a520069e53ec5afa977a316a5d36.tar.gz
git-4bbaa1eb6fb4a520069e53ec5afa977a316a5d36.tar.bz2
use commit_list_count() to count the members of commit_lists
Call commit_list_count() instead of open-coding it repeatedly. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/for-each-ref.c')
-rw-r--r--builtin/for-each-ref.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 4135980..47bd624 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -283,18 +283,6 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
}
}
-static int num_parents(struct commit *commit)
-{
- struct commit_list *parents;
- int i;
-
- for (i = 0, parents = commit->parents;
- parents;
- parents = parents->next)
- i++;
- return i;
-}
-
/* See grab_values */
static void grab_commit_values(struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
{
@@ -315,12 +303,12 @@ static void grab_commit_values(struct atom_value *val, int deref, struct object
}
if (!strcmp(name, "numparent")) {
char *s = xmalloc(40);
- v->ul = num_parents(commit);
+ v->ul = commit_list_count(commit->parents);
sprintf(s, "%lu", v->ul);
v->s = s;
}
else if (!strcmp(name, "parent")) {
- int num = num_parents(commit);
+ int num = commit_list_count(commit->parents);
int i;
struct commit_list *parents;
char *s = xmalloc(41 * num + 1);