Commit bce5dac1a3d52e5b3dc81458ca9b3a7d740180cb

Stefan Sperling 2020-01-28T09:51:38

display 'No repositories found in $got_repos_path" if gotweb finds no repos

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 8428efb..feeaec0 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -391,6 +391,15 @@ gw_index(struct gw_trans *gw_trans)
 
 	khttp_puts(gw_trans->gw_req, index_projects_header);
 
+	if (TAILQ_EMPTY(&gw_trans->gw_dirs)) {
+		if (asprintf(&html, index_projects_empty,
+		    gw_trans->gw_conf->got_repos_path) == -1)
+			return got_error_from_errno("asprintf");
+		khttp_puts(gw_trans->gw_req, html);
+		free(html);
+		return NULL;
+	}
+
 	TAILQ_FOREACH(gw_dir, &gw_trans->gw_dirs, entry)
 		dir_c++;
 
diff --git a/gotweb/gotweb_ui.h b/gotweb/gotweb_ui.h
index ba8f6bf..a34224a 100644
--- a/gotweb/gotweb_ui.h
+++ b/gotweb/gotweb_ui.h
@@ -290,6 +290,12 @@ char *index_projects =
 	"</div>" \
 	"<div id='dotted_line'></div>";
 
+char *index_projects_empty =
+	"<div id='index_wrapper'>" \
+	"No repositories found in %s" \
+	"</div>" \
+	"<div id='dotted_line'></div>";
+
 char *index_navs =
 	"<a href='?path=%s&action=summary'>summary</a> | " \
 	"<a href='?path=%s&action=briefs'>commit briefs</a> | " \