diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Give empty repositories their own page
Diffstat (limited to 'source/cgit.c')
-rw-r--r--source/cgit.c25
1 file changed, 7 insertions, 18 deletions
diff --git a/source/cgit.c b/source/cgit.c
index 412d5f3..1ab77a4 100644
--- a/source/cgit.c
+++ b/source/cgit.c
@@ -16,6 +16,7 @@
#include "ui-shared.h"
#include "ui-stats.h"
#include "ui-blob.h"
+#include "ui-empty.h"
#include "ui-summary.h"
#include "scan-tree.h"
@@ -603,17 +604,6 @@ static void choose_readme(struct cgit_repo *repo)
string_list_append(&repo->readme, filename)->util = ref;
}
-static void print_no_repo_clone_urls(const char *url)
-{
- html("<tr><td><a rel='vcs-git' href='");
- html_url_path(url);
- html("' title='");
- html_attr(ctx.repo->name);
- html(" Git repository'>");
- html_txt(url);
- html("</a></td></tr>\n");
-}
-
static void prepare_repo_env(int *nongit)
{
/* The path to the git repository. */
@@ -656,16 +646,15 @@ static int prepare_repo_cmd(int nongit)
}
if (!ctx.qry.head) {
+ ctx.empty_repo = 1;
+ // Before the document starts, since the <head> carries
+ // <link rel='vcs-git'> and those clone urls expand macros such
+ // as $CGIT_REPO_URL out of this environment.
+ cgit_prepare_repo_env(ctx.repo);
cgit_print_http_headers();
cgit_print_docstart();
cgit_print_pageheader();
- cgit_print_error("Repository seems to be empty");
- if (!strcmp(ctx.qry.page, "summary")) {
- html("<table class='list'><tr class='nohover'><td>&nbsp;</td></tr><tr class='nohover'><th class='left'>Clone</th></tr>\n");
- cgit_prepare_repo_env(ctx.repo);
- cgit_add_clone_urls(print_no_repo_clone_urls);
- html("</table>\n");
- }
+ cgit_print_empty_repo();
cgit_print_docend();
return 1;
}