blob: b5f90fc7f45aa15dc587db589d968e9b2b268f37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * The page a repository with no commits falls back to, an error line and then
 * the clone urls someone needs in order to push the first commit. cgit.c
 * prints this in place of whatever page was asked for as soon as it finds
 * there is no branch to resolve, so none of the ref driven pages ever run
 * against an empty repository.
 */

#include "cgit.h"
#include "html.h"
#include "ui-empty.h"
#include "ui-shared.h"

static void print_clone_url(const char *url)
{
	html("<tr><td class='clone-url'><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");
}

/*
 * The caller has already prepared the repo environment, which the clone urls
 * need for macro expansion.
 */
void cgit_print_empty_repo(void)
{
	cgit_print_error("Repository seems to be empty");

	// cgit_add_clone_urls draws on just these two, so with neither set the
	// table below would be a Clone heading with no rows.
	if (!ctx.repo->clone_url && !ctx.cfg.clone_prefix)
		return;

	html("<table summary='clone urls' class='list'>");
	html("<tr class='nohover'><th class='left'>Clone</th></tr>\n");
	cgit_add_clone_urls(print_clone_url);
	html("</table>\n");
}