|
diff --git a/cgit.c b/cgit.c index 90ae124..e281aa9 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -159,25 +159,25 @@ void config_cb(const char *name, const char *value) |
159 | else if (!strcmp(name, "max-message-length")) |
159 | else if (!strcmp(name, "max-message-length")) |
160 | ctx.cfg.max_msg_len = atoi(value); |
160 | ctx.cfg.max_msg_len = atoi(value); |
161 | else if (!strcmp(name, "max-repodesc-length")) |
161 | else if (!strcmp(name, "max-repodesc-length")) |
162 | ctx.cfg.max_repodesc_len = atoi(value); |
162 | ctx.cfg.max_repodesc_len = atoi(value); |
163 | else if (!strcmp(name, "max-repo-count")) |
163 | else if (!strcmp(name, "max-repo-count")) |
164 | ctx.cfg.max_repo_count = atoi(value); |
164 | ctx.cfg.max_repo_count = atoi(value); |
165 | else if (!strcmp(name, "max-commit-count")) |
165 | else if (!strcmp(name, "max-commit-count")) |
166 | ctx.cfg.max_commit_count = atoi(value); |
166 | ctx.cfg.max_commit_count = atoi(value); |
167 | else if (!strcmp(name, "scan-path")) |
167 | else if (!strcmp(name, "scan-path")) |
168 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
168 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) |
169 | process_cached_repolist(value); |
169 | process_cached_repolist(value); |
170 | else |
170 | else |
171 | scan_tree(value); |
171 | scan_tree(value, repo_config); |
172 | else if (!strcmp(name, "source-filter")) |
172 | else if (!strcmp(name, "source-filter")) |
173 | ctx.cfg.source_filter = new_filter(value, 1); |
173 | ctx.cfg.source_filter = new_filter(value, 1); |
174 | else if (!strcmp(name, "summary-log")) |
174 | else if (!strcmp(name, "summary-log")) |
175 | ctx.cfg.summary_log = atoi(value); |
175 | ctx.cfg.summary_log = atoi(value); |
176 | else if (!strcmp(name, "summary-branches")) |
176 | else if (!strcmp(name, "summary-branches")) |
177 | ctx.cfg.summary_branches = atoi(value); |
177 | ctx.cfg.summary_branches = atoi(value); |
178 | else if (!strcmp(name, "summary-tags")) |
178 | else if (!strcmp(name, "summary-tags")) |
179 | ctx.cfg.summary_tags = atoi(value); |
179 | ctx.cfg.summary_tags = atoi(value); |
180 | else if (!strcmp(name, "agefile")) |
180 | else if (!strcmp(name, "agefile")) |
181 | ctx.cfg.agefile = xstrdup(value); |
181 | ctx.cfg.agefile = xstrdup(value); |
182 | else if (!strcmp(name, "renamelimit")) |
182 | else if (!strcmp(name, "renamelimit")) |
183 | ctx.cfg.renamelimit = atoi(value); |
183 | ctx.cfg.renamelimit = atoi(value); |
@@ -467,49 +467,49 @@ static int generate_cached_repolist(const char *path, const char *cached_rc) |
467 | locked_rc = xstrdup(fmt("%s.lock", cached_rc)); |
467 | locked_rc = xstrdup(fmt("%s.lock", cached_rc)); |
468 | f = fopen(locked_rc, "wx"); |
468 | f = fopen(locked_rc, "wx"); |
469 | if (!f) { |
469 | if (!f) { |
470 | /* Inform about the error unless the lockfile already existed, |
470 | /* Inform about the error unless the lockfile already existed, |
471 | * since that only means we've got concurrent requests. |
471 | * since that only means we've got concurrent requests. |
472 | */ |
472 | */ |
473 | if (errno != EEXIST) |
473 | if (errno != EEXIST) |
474 | fprintf(stderr, "[cgit] Error opening %s: %s (%d)\n", |
474 | fprintf(stderr, "[cgit] Error opening %s: %s (%d)\n", |
475 | locked_rc, strerror(errno), errno); |
475 | locked_rc, strerror(errno), errno); |
476 | return errno; |
476 | return errno; |
477 | } |
477 | } |
478 | idx = cgit_repolist.count; |
478 | idx = cgit_repolist.count; |
479 | scan_tree(path); |
479 | scan_tree(path, repo_config); |
480 | print_repolist(f, &cgit_repolist, idx); |
480 | print_repolist(f, &cgit_repolist, idx); |
481 | if (rename(locked_rc, cached_rc)) |
481 | if (rename(locked_rc, cached_rc)) |
482 | fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n", |
482 | fprintf(stderr, "[cgit] Error renaming %s to %s: %s (%d)\n", |
483 | locked_rc, cached_rc, strerror(errno), errno); |
483 | locked_rc, cached_rc, strerror(errno), errno); |
484 | fclose(f); |
484 | fclose(f); |
485 | return 0; |
485 | return 0; |
486 | } |
486 | } |
487 | |
487 | |
488 | static void process_cached_repolist(const char *path) |
488 | static void process_cached_repolist(const char *path) |
489 | { |
489 | { |
490 | struct stat st; |
490 | struct stat st; |
491 | char *cached_rc; |
491 | char *cached_rc; |
492 | time_t age; |
492 | time_t age; |
493 | |
493 | |
494 | cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root, |
494 | cached_rc = xstrdup(fmt("%s/rc-%8x", ctx.cfg.cache_root, |
495 | hash_str(path))); |
495 | hash_str(path))); |
496 | |
496 | |
497 | if (stat(cached_rc, &st)) { |
497 | if (stat(cached_rc, &st)) { |
498 | /* Nothing is cached, we need to scan without forking. And |
498 | /* Nothing is cached, we need to scan without forking. And |
499 | * if we fail to generate a cached repolist, we need to |
499 | * if we fail to generate a cached repolist, we need to |
500 | * invoke scan_tree manually. |
500 | * invoke scan_tree manually. |
501 | */ |
501 | */ |
502 | if (generate_cached_repolist(path, cached_rc)) |
502 | if (generate_cached_repolist(path, cached_rc)) |
503 | scan_tree(path); |
503 | scan_tree(path, repo_config); |
504 | return; |
504 | return; |
505 | } |
505 | } |
506 | |
506 | |
507 | parse_configfile(cached_rc, config_cb); |
507 | parse_configfile(cached_rc, config_cb); |
508 | |
508 | |
509 | /* If the cached configfile hasn't expired, lets exit now */ |
509 | /* If the cached configfile hasn't expired, lets exit now */ |
510 | age = time(NULL) - st.st_mtime; |
510 | age = time(NULL) - st.st_mtime; |
511 | if (age <= (ctx.cfg.cache_scanrc_ttl * 60)) |
511 | if (age <= (ctx.cfg.cache_scanrc_ttl * 60)) |
512 | return; |
512 | return; |
513 | |
513 | |
514 | /* The cached repolist has been parsed, but it was old. So lets |
514 | /* The cached repolist has been parsed, but it was old. So lets |
515 | * rescan the specified path and generate a new cached repolist |
515 | * rescan the specified path and generate a new cached repolist |
@@ -550,25 +550,25 @@ static void cgit_parse_args(int argc, const char **argv) |
550 | ctx.qry.has_symref = 1; |
550 | ctx.qry.has_symref = 1; |
551 | } |
551 | } |
552 | if (!strncmp(argv[i], "--sha1=", 7)) { |
552 | if (!strncmp(argv[i], "--sha1=", 7)) { |
553 | ctx.qry.sha1 = xstrdup(argv[i]+7); |
553 | ctx.qry.sha1 = xstrdup(argv[i]+7); |
554 | ctx.qry.has_sha1 = 1; |
554 | ctx.qry.has_sha1 = 1; |
555 | } |
555 | } |
556 | if (!strncmp(argv[i], "--ofs=", 6)) { |
556 | if (!strncmp(argv[i], "--ofs=", 6)) { |
557 | ctx.qry.ofs = atoi(argv[i]+6); |
557 | ctx.qry.ofs = atoi(argv[i]+6); |
558 | } |
558 | } |
559 | if (!strncmp(argv[i], "--scan-tree=", 12) || |
559 | if (!strncmp(argv[i], "--scan-tree=", 12) || |
560 | !strncmp(argv[i], "--scan-path=", 12)) { |
560 | !strncmp(argv[i], "--scan-path=", 12)) { |
561 | scan++; |
561 | scan++; |
562 | scan_tree(argv[i] + 12); |
562 | scan_tree(argv[i] + 12, repo_config); |
563 | } |
563 | } |
564 | } |
564 | } |
565 | if (scan) { |
565 | if (scan) { |
566 | qsort(cgit_repolist.repos, cgit_repolist.count, |
566 | qsort(cgit_repolist.repos, cgit_repolist.count, |
567 | sizeof(struct cgit_repo), cmp_repos); |
567 | sizeof(struct cgit_repo), cmp_repos); |
568 | print_repolist(stdout, &cgit_repolist, 0); |
568 | print_repolist(stdout, &cgit_repolist, 0); |
569 | exit(0); |
569 | exit(0); |
570 | } |
570 | } |
571 | } |
571 | } |
572 | |
572 | |
573 | static int calc_ttl() |
573 | static int calc_ttl() |
574 | { |
574 | { |
|