summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-04-08 19:27:12 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-04-08 19:27:12 (UTC)
commitc6f747649ace1a92ed5dfaae9cc1ea3affe0bf51 (patch) (unidiff)
treec2d8ccd19974b6dfe32c5d3bffcfdf22dd526ae1
parente87e89633383b8b75c68c98be3e0c14212109de2 (diff)
downloadcgit-c6f747649ace1a92ed5dfaae9cc1ea3affe0bf51.zip
cgit-c6f747649ace1a92ed5dfaae9cc1ea3affe0bf51.tar.gz
cgit-c6f747649ace1a92ed5dfaae9cc1ea3affe0bf51.tar.bz2
Reset ctx.repo to NULL when the config parser is finished
This global variable is used by the config parsing callback to keep track of the currently configured repository. If it is not reset to NULL when the config parser is finished, and neither `url` or `r` is specified on the querystring, cgit will wrongly consider the last configured repo as selected. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index 763242a..6ec763f 100644
--- a/cgit.c
+++ b/cgit.c
@@ -419,40 +419,41 @@ static void cgit_parse_args(int argc, const char **argv)
419 } 419 }
420 if (!strncmp(argv[i], "--sha1=", 7)) { 420 if (!strncmp(argv[i], "--sha1=", 7)) {
421 ctx.qry.sha1 = xstrdup(argv[i]+7); 421 ctx.qry.sha1 = xstrdup(argv[i]+7);
422 ctx.qry.has_sha1 = 1; 422 ctx.qry.has_sha1 = 1;
423 } 423 }
424 if (!strncmp(argv[i], "--ofs=", 6)) { 424 if (!strncmp(argv[i], "--ofs=", 6)) {
425 ctx.qry.ofs = atoi(argv[i]+6); 425 ctx.qry.ofs = atoi(argv[i]+6);
426 } 426 }
427 } 427 }
428} 428}
429 429
430int main(int argc, const char **argv) 430int main(int argc, const char **argv)
431{ 431{
432 struct cacheitem item; 432 struct cacheitem item;
433 const char *cgit_config_env = getenv("CGIT_CONFIG"); 433 const char *cgit_config_env = getenv("CGIT_CONFIG");
434 434
435 prepare_context(&ctx); 435 prepare_context(&ctx);
436 item.st.st_mtime = time(NULL); 436 item.st.st_mtime = time(NULL);
437 cgit_repolist.length = 0; 437 cgit_repolist.length = 0;
438 cgit_repolist.count = 0; 438 cgit_repolist.count = 0;
439 cgit_repolist.repos = NULL; 439 cgit_repolist.repos = NULL;
440 440
441 parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG, 441 parse_configfile(cgit_config_env ? cgit_config_env : CGIT_CONFIG,
442 config_cb); 442 config_cb);
443 ctx.repo = NULL;
443 if (getenv("SCRIPT_NAME")) 444 if (getenv("SCRIPT_NAME"))
444 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME")); 445 ctx.cfg.script_name = xstrdup(getenv("SCRIPT_NAME"));
445 if (getenv("QUERY_STRING")) 446 if (getenv("QUERY_STRING"))
446 ctx.qry.raw = xstrdup(getenv("QUERY_STRING")); 447 ctx.qry.raw = xstrdup(getenv("QUERY_STRING"));
447 cgit_parse_args(argc, argv); 448 cgit_parse_args(argc, argv);
448 http_parse_querystring(ctx.qry.raw, querystring_cb); 449 http_parse_querystring(ctx.qry.raw, querystring_cb);
449 if (!cgit_prepare_cache(&item)) 450 if (!cgit_prepare_cache(&item))
450 return 0; 451 return 0;
451 if (ctx.cfg.nocache) { 452 if (ctx.cfg.nocache) {
452 cgit_fill_cache(&item, 0); 453 cgit_fill_cache(&item, 0);
453 } else { 454 } else {
454 cgit_check_cache(&item); 455 cgit_check_cache(&item);
455 cgit_print_cache(&item); 456 cgit_print_cache(&item);
456 } 457 }
457 return 0; 458 return 0;
458} 459}