aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/cgit.c b/cgit.c
index 6f75db1..4e51283 100644
--- a/cgit.c
+++ b/cgit.c
@@ -459,7 +459,6 @@ static char *guess_defbranch(void)
459 459
460static int prepare_repo_cmd(struct cgit_context *ctx) 460static int prepare_repo_cmd(struct cgit_context *ctx)
461{ 461{
462 char *tmp;
463 unsigned char sha1[20]; 462 unsigned char sha1[20];
464 int nongit = 0; 463 int nongit = 0;
465 int rc; 464 int rc;
@@ -467,17 +466,16 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
467 setenv("GIT_DIR", ctx->repo->path, 1); 466 setenv("GIT_DIR", ctx->repo->path, 1);
468 setup_git_directory_gently(&nongit); 467 setup_git_directory_gently(&nongit);
469 if (nongit) { 468 if (nongit) {
469 const char *name = ctx->repo->name;
470 rc = errno; 470 rc = errno;
471 ctx->page.title = fmt("%s - %s", ctx->cfg.root_title, 471 ctx->page.title = fmt("%s - %s", ctx->cfg.root_title,
472 "config error"); 472 "config error");
473 tmp = fmt("Failed to open %s: %s",
474 ctx->repo->name,
475 rc ? strerror(rc) : "Not a valid git repository");
476 ctx->repo = NULL; 473 ctx->repo = NULL;
477 cgit_print_http_headers(ctx); 474 cgit_print_http_headers(ctx);
478 cgit_print_docstart(ctx); 475 cgit_print_docstart(ctx);
479 cgit_print_pageheader(ctx); 476 cgit_print_pageheader(ctx);
480 cgit_print_error(tmp); 477 cgit_print_error("Failed to open %s: %s", name,
478 rc ? strerror(rc) : "Not a valid git repository");
481 cgit_print_docend(); 479 cgit_print_docend();
482 return 1; 480 return 1;
483 } 481 }
@@ -501,14 +499,14 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
501 } 499 }
502 500
503 if (get_sha1(ctx->qry.head, sha1)) { 501 if (get_sha1(ctx->qry.head, sha1)) {
504 tmp = xstrdup(ctx->qry.head); 502 char *tmp = xstrdup(ctx->qry.head);
505 ctx->qry.head = ctx->repo->defbranch; 503 ctx->qry.head = ctx->repo->defbranch;
506 ctx->page.status = 404; 504 ctx->page.status = 404;
507 ctx->page.statusmsg = "Not found"; 505 ctx->page.statusmsg = "Not found";
508 cgit_print_http_headers(ctx); 506 cgit_print_http_headers(ctx);
509 cgit_print_docstart(ctx); 507 cgit_print_docstart(ctx);
510 cgit_print_pageheader(ctx); 508 cgit_print_pageheader(ctx);
511 cgit_print_error(fmt("Invalid branch: %s", tmp)); 509 cgit_print_error("Invalid branch: %s", tmp);
512 cgit_print_docend(); 510 cgit_print_docend();
513 return 1; 511 return 1;
514 } 512 }
@@ -550,7 +548,7 @@ static void process_request(void *cbdata)
550 cgit_print_http_headers(ctx); 548 cgit_print_http_headers(ctx);
551 cgit_print_docstart(ctx); 549 cgit_print_docstart(ctx);
552 cgit_print_pageheader(ctx); 550 cgit_print_pageheader(ctx);
553 cgit_print_error(fmt("No repository selected")); 551 cgit_print_error("No repository selected");
554 cgit_print_docend(); 552 cgit_print_docend();
555 return; 553 return;
556 } 554 }
@@ -862,7 +860,7 @@ int main(int argc, const char **argv)
862 err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root, 860 err = cache_process(ctx.cfg.cache_size, ctx.cfg.cache_root,
863 ctx.qry.raw, ttl, process_request, &ctx); 861 ctx.qry.raw, ttl, process_request, &ctx);
864 if (err) 862 if (err)
865 cgit_print_error(fmt("Error processing page: %s (%d)", 863 cgit_print_error("Error processing page: %s (%d)",
866 strerror(err), err)); 864 strerror(err), err);
867 return err; 865 return err;
868} 866}