diff options
Diffstat (limited to 'cgit.c')
| -rw-r--r-- | cgit.c | 17 |
1 files changed, 8 insertions, 9 deletions
| @@ -83,20 +83,23 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 83 | char *title, *tmp; | 83 | char *title, *tmp; |
| 84 | int show_search; | 84 | int show_search; |
| 85 | unsigned char sha1[20]; | 85 | unsigned char sha1[20]; |
| 86 | int nongit = 0; | ||
| 86 | 87 | ||
| 87 | if (chdir(ctx.repo->path)) { | 88 | setenv("GIT_DIR", ctx.repo->path, 1); |
| 88 | title = fmt("%s - %s", ctx.cfg.root_title, "Bad request"); | 89 | setup_git_directory_gently(&nongit); |
| 90 | if (nongit) { | ||
| 91 | title = fmt("%s - %s", ctx.cfg.root_title, "config error"); | ||
| 92 | tmp = fmt("Not a git repository: '%s'", ctx.repo->path); | ||
| 93 | ctx.repo = NULL; | ||
| 89 | cgit_print_docstart(title, item); | 94 | cgit_print_docstart(title, item); |
| 90 | cgit_print_pageheader(title, 0); | 95 | cgit_print_pageheader(title, 0); |
| 91 | cgit_print_error(fmt("Unable to scan repository: %s", | 96 | cgit_print_error(tmp); |
| 92 | strerror(errno))); | ||
| 93 | cgit_print_docend(); | 97 | cgit_print_docend(); |
| 94 | return; | 98 | return; |
| 95 | } | 99 | } |
| 96 | 100 | ||
| 97 | title = fmt("%s - %s", ctx.repo->name, ctx.repo->desc); | 101 | title = fmt("%s - %s", ctx.repo->name, ctx.repo->desc); |
| 98 | show_search = 0; | 102 | show_search = 0; |
| 99 | setenv("GIT_DIR", ctx.repo->path, 1); | ||
| 100 | 103 | ||
| 101 | if (!ctx.qry.head) { | 104 | if (!ctx.qry.head) { |
| 102 | ctx.qry.head = xstrdup(find_default_branch(ctx.repo)); | 105 | ctx.qry.head = xstrdup(find_default_branch(ctx.repo)); |
| @@ -179,10 +182,8 @@ static void cgit_print_repo_page(struct cacheitem *item) | |||
| 179 | 182 | ||
| 180 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) | 183 | static void cgit_fill_cache(struct cacheitem *item, int use_cache) |
| 181 | { | 184 | { |
| 182 | static char buf[PATH_MAX]; | ||
| 183 | int stdout2; | 185 | int stdout2; |
| 184 | 186 | ||
| 185 | getcwd(buf, sizeof(buf)); | ||
| 186 | item->st.st_mtime = time(NULL); | 187 | item->st.st_mtime = time(NULL); |
| 187 | 188 | ||
| 188 | if (use_cache) { | 189 | if (use_cache) { |
| @@ -203,8 +204,6 @@ static void cgit_fill_cache(struct cacheitem *item, int use_cache) | |||
| 203 | "Restoring original STDOUT"); | 204 | "Restoring original STDOUT"); |
| 204 | chk_zero(close(stdout2), "Closing temporary STDOUT"); | 205 | chk_zero(close(stdout2), "Closing temporary STDOUT"); |
| 205 | } | 206 | } |
| 206 | |||
| 207 | chdir(buf); | ||
| 208 | } | 207 | } |
| 209 | 208 | ||
| 210 | static void cgit_check_cache(struct cacheitem *item) | 209 | static void cgit_check_cache(struct cacheitem *item) |
