author | Lars Hjemli <hjemli@gmail.com> | 2007-01-17 00:09:51 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-01-17 00:09:51 (UTC) |
commit | a69061fdb7380d73715aeb3a0da6e91a24df90e4 (patch) (unidiff) | |
tree | bb514d5bfbab6e3b2904b2633a33175802f084d2 /parsing.c | |
parent | 06c81d6faafff1c80bc9e2302e5b8fea393b775b (diff) | |
download | cgit-a69061fdb7380d73715aeb3a0da6e91a24df90e4.zip cgit-a69061fdb7380d73715aeb3a0da6e91a24df90e4.tar.gz cgit-a69061fdb7380d73715aeb3a0da6e91a24df90e4.tar.bz2 |
Add function cgit_parse_tag()
Teach cgit how to extract author info from a tag.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | parsing.c | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -191,8 +191,55 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) | |||
191 | p = t + 1; | 191 | p = t + 1; |
192 | 192 | ||
193 | while (*p == '\n') | 193 | while (*p == '\n') |
194 | p = strchr(p, '\n') + 1; | 194 | p = strchr(p, '\n') + 1; |
195 | ret->msg = p; | 195 | ret->msg = p; |
196 | } | 196 | } |
197 | return ret; | 197 | return ret; |
198 | } | 198 | } |
199 | |||
200 | |||
201 | struct taginfo *cgit_parse_tag(struct tag *tag) | ||
202 | { | ||
203 | void *data; | ||
204 | char type[20]; | ||
205 | unsigned long size; | ||
206 | char *p, *t; | ||
207 | struct taginfo *ret; | ||
208 | |||
209 | data = read_sha1_file(tag->object.sha1, type, &size); | ||
210 | if (!data || strcmp(type, tag_type)) { | ||
211 | free(data); | ||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | ret = xmalloc(sizeof(*ret)); | ||
216 | ret->tagger = NULL; | ||
217 | ret->tagger_email = NULL; | ||
218 | ret->tagger_date = 0; | ||
219 | ret->msg = NULL; | ||
220 | |||
221 | p = data; | ||
222 | |||
223 | while (p) { | ||
224 | if (*p == '\n') | ||
225 | break; | ||
226 | |||
227 | if (!strncmp(p, "tagger ", 7)) { | ||
228 | p += 7; | ||
229 | t = strchr(p, '<') - 1; | ||
230 | ret->tagger = substr(p, t); | ||
231 | p = t; | ||
232 | t = strchr(t, '>') + 1; | ||
233 | ret->tagger_email = substr(p, t); | ||
234 | ret->tagger_date = atol(++t); | ||
235 | } | ||
236 | p = strchr(p, '\n') + 1; | ||
237 | } | ||
238 | |||
239 | while (p && (*p == '\n')) | ||
240 | p = strchr(p, '\n') + 1; | ||
241 | if (p) | ||
242 | ret->msg = xstrdup(p); | ||
243 | free(data); | ||
244 | return ret; | ||
245 | } | ||