summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--parsing.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/parsing.c b/parsing.c
index 4420e58..b86467a 100644
--- a/parsing.c
+++ b/parsing.c
@@ -205,72 +205,77 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
205 else 205 else
206 p += 46; // "tree " + hex[40] + "\n" 206 p += 46; // "tree " + hex[40] + "\n"
207 207
208 while (!strncmp(p, "parent ", 7)) 208 while (!strncmp(p, "parent ", 7))
209 p += 48; // "parent " + hex[40] + "\n" 209 p += 48; // "parent " + hex[40] + "\n"
210 210
211 if (!strncmp(p, "author ", 7)) { 211 if (!strncmp(p, "author ", 7)) {
212 p += 7; 212 p += 7;
213 t = strchr(p, '<') - 1; 213 t = strchr(p, '<') - 1;
214 ret->author = substr(p, t); 214 ret->author = substr(p, t);
215 p = t; 215 p = t;
216 t = strchr(t, '>') + 1; 216 t = strchr(t, '>') + 1;
217 ret->author_email = substr(p, t); 217 ret->author_email = substr(p, t);
218 ret->author_date = atol(++t); 218 ret->author_date = atol(++t);
219 p = strchr(t, '\n') + 1; 219 p = strchr(t, '\n') + 1;
220 } 220 }
221 221
222 if (!strncmp(p, "committer ", 9)) { 222 if (!strncmp(p, "committer ", 9)) {
223 p += 9; 223 p += 9;
224 t = strchr(p, '<') - 1; 224 t = strchr(p, '<') - 1;
225 ret->committer = substr(p, t); 225 ret->committer = substr(p, t);
226 p = t; 226 p = t;
227 t = strchr(t, '>') + 1; 227 t = strchr(t, '>') + 1;
228 ret->committer_email = substr(p, t); 228 ret->committer_email = substr(p, t);
229 ret->committer_date = atol(++t); 229 ret->committer_date = atol(++t);
230 p = strchr(t, '\n') + 1; 230 p = strchr(t, '\n') + 1;
231 } 231 }
232 232
233 while (*p == '\n') 233 while (*p == '\n')
234 p = strchr(p, '\n') + 1; 234 p = strchr(p, '\n') + 1;
235 235
236 t = strchr(p, '\n'); 236 t = strchr(p, '\n');
237 if (t && *t) { 237 if (t) {
238 ret->subject = substr(p, t); 238 if (*t == '\0')
239 ret->subject = strdup("** empty **");
240 else
241 ret->subject = substr(p, t);
239 p = t + 1; 242 p = t + 1;
240 243
241 while (*p == '\n') 244 while (*p == '\n')
242 p = strchr(p, '\n') + 1; 245 p = strchr(p, '\n') + 1;
243 ret->msg = p; 246 ret->msg = p;
244 } 247 } else
248 ret->subject = substr(p, p+strlen(p));
249
245 return ret; 250 return ret;
246} 251}
247 252
248 253
249struct taginfo *cgit_parse_tag(struct tag *tag) 254struct taginfo *cgit_parse_tag(struct tag *tag)
250{ 255{
251 void *data; 256 void *data;
252 enum object_type type; 257 enum object_type type;
253 unsigned long size; 258 unsigned long size;
254 char *p, *t; 259 char *p, *t;
255 struct taginfo *ret; 260 struct taginfo *ret;
256 261
257 data = read_sha1_file(tag->object.sha1, &type, &size); 262 data = read_sha1_file(tag->object.sha1, &type, &size);
258 if (!data || type != OBJ_TAG) { 263 if (!data || type != OBJ_TAG) {
259 free(data); 264 free(data);
260 return 0; 265 return 0;
261 } 266 }
262 267
263 ret = xmalloc(sizeof(*ret)); 268 ret = xmalloc(sizeof(*ret));
264 ret->tagger = NULL; 269 ret->tagger = NULL;
265 ret->tagger_email = NULL; 270 ret->tagger_email = NULL;
266 ret->tagger_date = 0; 271 ret->tagger_date = 0;
267 ret->msg = NULL; 272 ret->msg = NULL;
268 273
269 p = data; 274 p = data;
270 275
271 while (p && *p) { 276 while (p && *p) {
272 if (*p == '\n') 277 if (*p == '\n')
273 break; 278 break;
274 279
275 if (!strncmp(p, "tagger ", 7)) { 280 if (!strncmp(p, "tagger ", 7)) {
276 p += 7; 281 p += 7;