author | Lars Hjemli <hjemli@gmail.com> | 2008-07-27 10:32:08 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-07-27 10:32:08 (UTC) |
commit | 25c84326deff579d5de4b880f9dca2690bdc8569 (patch) (side-by-side diff) | |
tree | 9ca41073e0e06e6dc24f7800182bf4a7b22f548c /ui-shared.c | |
parent | 2d6ee032d0c2f84ebcfaa12d3289e85cfab18fcd (diff) | |
download | cgit-25c84326deff579d5de4b880f9dca2690bdc8569.zip cgit-25c84326deff579d5de4b880f9dca2690bdc8569.tar.gz cgit-25c84326deff579d5de4b880f9dca2690bdc8569.tar.bz2 |
Be prepared for empty repositories
Before this patch, cgit would segfault on repositories with no refs.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index 209af6e..4280a70 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -489,65 +489,66 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) return 0; hashcpy(fileid, tag->tagged->sha1); } else if (obj->type != OBJ_BLOB) { return 0; } else { hashcpy(fileid, sha1); } if (!*header) { html("<h1>download</h1>\n"); *header = 1; } url = cgit_pageurl(ctx.qry.repo, "blob", fmt("id=%s&path=%s", sha1_to_hex(fileid), buf)); html_link_open(url, NULL, "menu"); html_txt(strlpart(buf, 20)); html_link_close(); return 0; } void add_hidden_formfields(int incl_head, int incl_search, char *page) { char *url; if (!ctx.cfg.virtual_root) { url = fmt("%s/%s", ctx.qry.repo, page); if (ctx.qry.path) url = fmt("%s/%s", url, ctx.qry.path); html_hidden("url", url); } - if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) + if (incl_head && ctx.qry.head && ctx.repo->defbranch && + strcmp(ctx.qry.head, ctx.repo->defbranch)) html_hidden("h", ctx.qry.head); if (ctx.qry.sha1) html_hidden("id", ctx.qry.sha1); if (ctx.qry.sha2) html_hidden("id2", ctx.qry.sha2); if (incl_search) { if (ctx.qry.grep) html_hidden("qt", ctx.qry.grep); if (ctx.qry.search) html_hidden("q", ctx.qry.search); } } char *hc(struct cgit_cmd *cmd, const char *page) { return (strcmp(cmd->name, page) ? NULL : "active"); } void cgit_print_pageheader(struct cgit_context *ctx) { struct cgit_cmd *cmd = cgit_get_cmd(ctx); html("<table id='header'>\n"); html("<tr>\n"); html("<td class='logo' rowspan='2'><a href='"); if (ctx->cfg.logo_link) html_attr(ctx->cfg.logo_link); else html_attr(cgit_rooturl()); html("'><img src='"); |