+ cgit_print_pageheader(title, 0);
+ cgit_print_error(fmt("Unknown repo: %s", cgit_query_repo));
+ cgit_print_docend();
+ return 0;
+ }
+
+ if (!cgit_repo) {
+ item->name = xstrdup(fmt("%s/index.html", cgit_cache_root));
+ item->ttl = cgit_cache_root_ttl;
+ return 1;
+ }
+
+ if (!cgit_cmd) {
+ item->name = xstrdup(fmt("%s/%s/index.html", cgit_cache_root,
+ cache_safe_filename(cgit_repo->url)));
+ item->ttl = cgit_cache_repo_ttl;
+ } else {
+ item->name = xstrdup(fmt("%s/%s/%s/%s.html", cgit_cache_root,
+ cache_safe_filename(cgit_repo->url), cgit_query_page,
+ cache_safe_filename(cgit_querystring)));
+ if (cgit_query_has_symref)
+ item->ttl = cgit_cache_dynamic_ttl;
+ else if (cgit_query_has_sha1)
+ item->ttl = cgit_cache_static_ttl;
+ else
+ item->ttl = cgit_cache_repo_ttl;
+ }
+ return 1;
+}
+
+static void cgit_print_repo_page(struct cacheitem *item)
+{
+ char *title;
+ int show_search;
+
+ if (!cgit_query_head)
+ cgit_query_head = cgit_repo->defbranch;
+
+ if (chdir(cgit_repo->path)) {
+ title = fmt("%s - %s", cgit_root_title, "Bad request");
+ cgit_print_docstart(title, item);
+ cgit_print_pageheader(title, 0);