summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--cgit.h2
-rw-r--r--ui-shared.c2
3 files changed, 6 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index 64d95f9..19adadd 100644
--- a/cgit.c
+++ b/cgit.c
@@ -282,12 +282,14 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
282 return 1; 282 return 1;
283 } 283 }
284 284
285 if (get_sha1(ctx->qry.head, sha1)) { 285 if (get_sha1(ctx->qry.head, sha1)) {
286 tmp = xstrdup(ctx->qry.head); 286 tmp = xstrdup(ctx->qry.head);
287 ctx->qry.head = ctx->repo->defbranch; 287 ctx->qry.head = ctx->repo->defbranch;
288 ctx->page.status = 404;
289 ctx->page.statusmsg = "not found";
288 cgit_print_http_headers(ctx); 290 cgit_print_http_headers(ctx);
289 cgit_print_docstart(ctx); 291 cgit_print_docstart(ctx);
290 cgit_print_pageheader(ctx); 292 cgit_print_pageheader(ctx);
291 cgit_print_error(fmt("Invalid branch: %s", tmp)); 293 cgit_print_error(fmt("Invalid branch: %s", tmp));
292 cgit_print_docend(); 294 cgit_print_docend();
293 return 1; 295 return 1;
diff --git a/cgit.h b/cgit.h
index 5f7af51..00aca4c 100644
--- a/cgit.h
+++ b/cgit.h
@@ -178,12 +178,14 @@ struct cgit_page {
178 time_t expires; 178 time_t expires;
179 size_t size; 179 size_t size;
180 char *mimetype; 180 char *mimetype;
181 char *charset; 181 char *charset;
182 char *filename; 182 char *filename;
183 char *title; 183 char *title;
184 int status;
185 char *statusmsg;
184}; 186};
185 187
186struct cgit_context { 188struct cgit_context {
187 struct cgit_query qry; 189 struct cgit_query qry;
188 struct cgit_config cfg; 190 struct cgit_config cfg;
189 struct cgit_repo *repo; 191 struct cgit_repo *repo;
diff --git a/ui-shared.c b/ui-shared.c
index 5ce2bc5..29036d0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -464,12 +464,14 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
464 htmlf("<span class='age-years'>%.0f years</span>", 464 htmlf("<span class='age-years'>%.0f years</span>",
465 secs * 1.0 / TM_YEAR); 465 secs * 1.0 / TM_YEAR);
466} 466}
467 467
468void cgit_print_http_headers(struct cgit_context *ctx) 468void cgit_print_http_headers(struct cgit_context *ctx)
469{ 469{
470 if (ctx->page.status)
471 htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg);
470 if (ctx->page.mimetype && ctx->page.charset) 472 if (ctx->page.mimetype && ctx->page.charset)
471 htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, 473 htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype,
472 ctx->page.charset); 474 ctx->page.charset);
473 else if (ctx->page.mimetype) 475 else if (ctx->page.mimetype)
474 htmlf("Content-Type: %s\n", ctx->page.mimetype); 476 htmlf("Content-Type: %s\n", ctx->page.mimetype);
475 if (ctx->page.size) 477 if (ctx->page.size)