summaryrefslogtreecommitdiffabout
path: root/cgit.c
Side-by-side diff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/cgit.c b/cgit.c
index bbde64b..d37abc9 100644
--- a/cgit.c
+++ b/cgit.c
@@ -298,25 +298,34 @@ static void process_request(struct cgit_context *ctx)
cmd = cgit_get_cmd(ctx);
if (!cmd) {
ctx->page.title = "cgit error";
ctx->repo = NULL;
cgit_print_http_headers(ctx);
cgit_print_docstart(ctx);
cgit_print_pageheader(ctx);
cgit_print_error("Invalid request");
cgit_print_docend();
return;
}
- if (cmd->want_repo && prepare_repo_cmd(ctx))
+ if (cmd->want_repo && !ctx->repo) {
+ cgit_print_http_headers(ctx);
+ cgit_print_docstart(ctx);
+ cgit_print_pageheader(ctx);
+ cgit_print_error(fmt("No repository selected"));
+ cgit_print_docend();
+ return;
+ }
+
+ if (ctx->repo && prepare_repo_cmd(ctx))
return;
if (cmd->want_layout) {
cgit_print_http_headers(ctx);
cgit_print_docstart(ctx);
cgit_print_pageheader(ctx);
}
cmd->fn(ctx);
if (cmd->want_layout)
cgit_print_docend();