Diffstat (limited to 'parsing.c')
| -rw-r--r-- | parsing.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -6,8 +6,6 @@ * (see COPYING for full license text) */ -#define USE_THE_REPOSITORY_VARIABLE - #include "cgit.h" /* @@ -19,7 +17,7 @@ */ void cgit_parse_url(const char *url) { - char *c, *cmd, *p, *buf; + char *c, *cmd, *p; struct cgit_repo *repo; if (!url || url[0] == '\0') @@ -32,12 +30,11 @@ void cgit_parse_url(const char *url) return; } - buf = xstrdup(url); cmd = NULL; - c = strchr(buf, '/'); + c = strchr(url, '/'); while (c) { c[0] = '\0'; - repo = cgit_get_repoinfo(buf); + repo = cgit_get_repoinfo(url); if (repo) { ctx.repo = repo; cmd = c; @@ -57,7 +54,6 @@ void cgit_parse_url(const char *url) if (cmd[1]) ctx.qry.page = xstrdup(cmd + 1); } - free(buf); } static char *substr(const char *head, const char *tail) @@ -131,6 +127,7 @@ static int end_of_header(const char *p) struct commitinfo *cgit_parse_commit(struct commit *commit) { + const int sha1hex_len = 40; struct commitinfo *ret; const char *p = repo_get_commit_buffer(the_repository, commit, NULL); const char *t; @@ -143,10 +140,10 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) if (!skip_prefix(p, "tree ", &p)) die("Bad commit: %s", oid_to_hex(&commit->object.oid)); - p += the_hash_algo->hexsz + 1; + p += sha1hex_len + 1; while (skip_prefix(p, "parent ", &p)) - p += the_hash_algo->hexsz + 1; + p += sha1hex_len + 1; if (p && skip_prefix(p, "author ", &p)) { parse_user(p, &ret->author, &ret->author_email, @@ -202,7 +199,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) const char *p; struct taginfo *ret = NULL; - data = odb_read_object(the_repository->objects, &tag->object.oid, &type, &size); + data = read_object_file(&tag->object.oid, &type, &size); if (!data || type != OBJ_TAG) goto cleanup; |