summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2008-07-27 10:32:08 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-07-27 10:32:08 (UTC)
commit25c84326deff579d5de4b880f9dca2690bdc8569 (patch) (unidiff)
tree9ca41073e0e06e6dc24f7800182bf4a7b22f548c /ui-shared.c
parent2d6ee032d0c2f84ebcfaa12d3289e85cfab18fcd (diff)
downloadcgit-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>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c3
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
@@ -515,13 +515,14 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
515 url = fmt("%s/%s", ctx.qry.repo, page); 515 url = fmt("%s/%s", ctx.qry.repo, page);
516 if (ctx.qry.path) 516 if (ctx.qry.path)
517 url = fmt("%s/%s", url, ctx.qry.path); 517 url = fmt("%s/%s", url, ctx.qry.path);
518 html_hidden("url", url); 518 html_hidden("url", url);
519 } 519 }
520 520
521 if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch)) 521 if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
522 strcmp(ctx.qry.head, ctx.repo->defbranch))
522 html_hidden("h", ctx.qry.head); 523 html_hidden("h", ctx.qry.head);
523 524
524 if (ctx.qry.sha1) 525 if (ctx.qry.sha1)
525 html_hidden("id", ctx.qry.sha1); 526 html_hidden("id", ctx.qry.sha1);
526 if (ctx.qry.sha2) 527 if (ctx.qry.sha2)
527 html_hidden("id2", ctx.qry.sha2); 528 html_hidden("id2", ctx.qry.sha2);