-
- if (chdir(cgit_repo->path)) {
- title = fmt("%s - %s", cgit_root_title, "Bad request");
- cgit_print_docstart(title, item);
- cgit_print_pageheader(title, 0);
- cgit_print_error(fmt("Unable to scan repository: %s",
- strerror(errno)));
+ int nongit = 0;
+
+ setenv("GIT_DIR", ctx.repo->path, 1);
+ setup_git_directory_gently(&nongit);
+ if (nongit) {
+ ctx.page.title = fmt("%s - %s", ctx.cfg.root_title,
+ "config error");
+ tmp = fmt("Not a git repository: '%s'", ctx.repo->path);
+ ctx.repo = NULL;
+ cgit_print_http_headers(&ctx);
+ cgit_print_docstart(&ctx);
+ cgit_print_pageheader(&ctx);
+ cgit_print_error(tmp);