summaryrefslogtreecommitdiff
path: root/parsing.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2007-01-17 01:09:51 +0100
committerLars Hjemli <hjemli@gmail.com>2007-01-17 01:09:51 +0100
commita69061fdb7380d73715aeb3a0da6e91a24df90e4 (patch)
treebb514d5bfbab6e3b2904b2633a33175802f084d2 /parsing.c
parent06c81d6faafff1c80bc9e2302e5b8fea393b775b (diff)
downloadcgit-a69061fdb7380d73715aeb3a0da6e91a24df90e4.tar.gz
cgit-a69061fdb7380d73715aeb3a0da6e91a24df90e4.tar.bz2
cgit-a69061fdb7380d73715aeb3a0da6e91a24df90e4.zip
Add function cgit_parse_tag()
Teach cgit how to extract author info from a tag. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to '')
-rw-r--r--parsing.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/parsing.c b/parsing.c
index 4412dee..8aad1dd 100644
--- a/parsing.c
+++ b/parsing.c
@@ -196,3 +196,50 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
}
return ret;
}
+
+
+struct taginfo *cgit_parse_tag(struct tag *tag)
+{
+ void *data;
+ char type[20];
+ unsigned long size;
+ char *p, *t;
+ struct taginfo *ret;
+
+ data = read_sha1_file(tag->object.sha1, type, &size);
+ if (!data || strcmp(type, tag_type)) {
+ free(data);
+ return 0;
+ }
+
+ ret = xmalloc(sizeof(*ret));
+ ret->tagger = NULL;
+ ret->tagger_email = NULL;
+ ret->tagger_date = 0;
+ ret->msg = NULL;
+
+ p = data;
+
+ while (p) {
+ if (*p == '\n')
+ break;
+
+ if (!strncmp(p, "tagger ", 7)) {
+ p += 7;
+ t = strchr(p, '<') - 1;
+ ret->tagger = substr(p, t);
+ p = t;
+ t = strchr(t, '>') + 1;
+ ret->tagger_email = substr(p, t);
+ ret->tagger_date = atol(++t);
+ }
+ p = strchr(p, '\n') + 1;
+ }
+
+ while (p && (*p == '\n'))
+ p = strchr(p, '\n') + 1;
+ if (p)
+ ret->msg = xstrdup(p);
+ free(data);
+ return ret;
+}