aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgit.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c
index a3702c2..bd9cb3f 100644
--- a/cgit.c
+++ b/cgit.c
@@ -561,12 +561,8 @@ static void print_no_repo_clone_urls(const char *url)
561 html("</a></td></tr>\n"); 561 html("</a></td></tr>\n");
562} 562}
563 563
564static int prepare_repo_cmd(void) 564static void prepare_repo_env(int *nongit)
565{ 565{
566 struct object_id oid;
567 int nongit = 0;
568 int rc;
569
570 /* The path to the git repository. */ 566 /* The path to the git repository. */
571 setenv("GIT_DIR", ctx.repo->path, 1); 567 setenv("GIT_DIR", ctx.repo->path, 1);
572 568
@@ -579,8 +575,13 @@ static int prepare_repo_cmd(void)
579 /* Setup the git directory and initialize the notes system. Both of these 575 /* Setup the git directory and initialize the notes system. Both of these
580 * load local configuration from the git repository, so we do them both while 576 * load local configuration from the git repository, so we do them both while
581 * the HOME variables are unset. */ 577 * the HOME variables are unset. */
582 setup_git_directory_gently(&nongit); 578 setup_git_directory_gently(nongit);
583 init_display_notes(NULL); 579 init_display_notes(NULL);
580}
581static int prepare_repo_cmd(int nongit)
582{
583 struct object_id oid;
584 int rc;
584 585
585 if (nongit) { 586 if (nongit) {
586 const char *name = ctx.repo->name; 587 const char *name = ctx.repo->name;
@@ -700,6 +701,7 @@ static inline void authenticate_cookie(void)
700static void process_request(void) 701static void process_request(void)
701{ 702{
702 struct cgit_cmd *cmd; 703 struct cgit_cmd *cmd;
704 int nongit = 0;
703 705
704 /* If we're not yet authenticated, no matter what page we're on, 706 /* If we're not yet authenticated, no matter what page we're on,
705 * display the authentication body from the auth_filter. This should 707 * display the authentication body from the auth_filter. This should
@@ -715,6 +717,9 @@ static void process_request(void)
715 return; 717 return;
716 } 718 }
717 719
720 if (ctx.repo)
721 prepare_repo_env(&nongit);
722
718 cmd = cgit_get_cmd(); 723 cmd = cgit_get_cmd();
719 if (!cmd) { 724 if (!cmd) {
720 ctx.page.title = "cgit error"; 725 ctx.page.title = "cgit error";
@@ -740,7 +745,7 @@ static void process_request(void)
740 */ 745 */
741 ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL; 746 ctx.qry.vpath = cmd->want_vpath ? ctx.qry.path : NULL;
742 747
743 if (ctx.repo && prepare_repo_cmd()) 748 if (ctx.repo && prepare_repo_cmd(nongit))
744 return; 749 return;
745 750
746 cmd->fn(); 751 cmd->fn();