diff options
author | Lars Hjemli <hjemli@gmail.com> | 2009-09-14 05:02:07 (JST) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2009-09-14 05:02:07 (JST) |
commit | 92f6940975f6771f3a08d497c02575ee5bdc79da (patch) | |
tree | c1c538b24e50be3bf63356acf246cda76b91c519 | |
parent | 5f12e45fe3338095916a444ff106dd9fc9991d84 (diff) | |
parent | ee554849ac7209fa8f7486327ec9f3b370e4c876 (diff) | |
download | cgit-92f6940975f6771f3a08d497c02575ee5bdc79da.zip cgit-92f6940975f6771f3a08d497c02575ee5bdc79da.tar.gz |
Merge branch 'lh/repo-scan'
-rw-r--r-- | cache.h | 2 | ||||
-rw-r--r-- | cgit.c | 265 | ||||
-rw-r--r-- | cgit.css | 2 | ||||
-rw-r--r-- | cgit.h | 9 | ||||
-rw-r--r-- | cgitrc.5.txt | 48 | ||||
-rw-r--r-- | scan-tree.c | 32 | ||||
-rw-r--r-- | scan-tree.h | 2 | ||||
-rw-r--r-- | shared.c | 3 | ||||
-rw-r--r-- | ui-repolist.c | 37 | ||||
-rw-r--r-- | ui-stats.c | 8 | ||||
-rw-r--r-- | ui-stats.h | 1 |
11 files changed, 329 insertions, 80 deletions
@@ -32,4 +32,6 @@ extern int cache_ls(const char *path); | |||
32 | /* Print a message to stdout */ | 32 | /* Print a message to stdout */ |
33 | extern void cache_log(const char *format, ...); | 33 | extern void cache_log(const char *format, ...); |
34 | 34 | ||
35 | extern unsigned long hash_str(const char *str); | ||
36 | |||
35 | #endif /* CGIT_CACHE_H */ | 37 | #endif /* CGIT_CACHE_H */ |
@@ -40,9 +40,58 @@ struct cgit_filter *new_filter(const char *cmd, int extra_args) | |||
40 | return f; | 40 | return f; |
41 | } | 41 | } |
42 | 42 | ||
43 | static void process_cached_repolist(const char *path); | ||
44 | |||
45 | void repo_config(struct cgit_repo *repo, const char *name, const char *value) | ||
46 | { | ||
47 | if (!strcmp(name, "name")) | ||
48 | repo->name = xstrdup(value); | ||
49 | else if (!strcmp(name, "clone-url")) | ||
50 | repo->clone_url = xstrdup(value); | ||
51 | else if (!strcmp(name, "desc")) | ||
52 | repo->desc = xstrdup(value); | ||
53 | else if (!strcmp(name, "owner")) | ||
54 | repo->owner = xstrdup(value); | ||
55 | else if (!strcmp(name, "defbranch")) | ||
56 | repo->defbranch = xstrdup(value); | ||
57 | else if (!strcmp(name, "snapshots")) | ||
58 | repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); | ||
59 | else if (!strcmp(name, "enable-log-filecount")) | ||
60 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | ||
61 | else if (!strcmp(name, "enable-log-linecount")) | ||
62 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | ||
63 | else if (!strcmp(name, "max-stats")) | ||
64 | repo->max_stats = cgit_find_stats_period(value, NULL); | ||
65 | else if (!strcmp(name, "module-link")) | ||
66 | repo->module_link= xstrdup(value); | ||
67 | else if (!strcmp(name, "section")) | ||
68 | repo->section = xstrdup(value); | ||
69 | else if (!strcmp(name, "readme") && value != NULL) { | ||
70 | if (*value == '/') | ||
71 | ctx.repo->readme = xstrdup(value); | ||
72 | else | ||
73 | ctx.repo->readme = xstrdup(fmt("%s/%s", ctx.repo->path, value)); | ||
74 | } else if (ctx.cfg.enable_filter_overrides) { | ||
75 | if (!strcmp(name, "about-filter")) | ||
76 | repo->about_filter = new_filter(value, 0); | ||
77 | else if (!strcmp(name, "commit-filter")) | ||
78 | repo->commit_filter = new_filter(value, 0); | ||
79 | else if (!strcmp(name, "source-filter")) | ||
80 | repo->source_filter = new_filter(value, 1); | ||
81 | } | ||
82 | } | ||
83 | |||
43 | void config_cb(const char *name, const char *value) | 84 | void config_cb(const char *name, const char *value) |
44 | { | 85 | { |
45 | if (!strcmp(name, "root-title")) | 86 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) |
87 | ctx.cfg.section = xstrdup(value); | ||
88 | else if (!strcmp(name, "repo.url")) | ||
89 | ctx.repo = cgit_add_repo(value); | ||
90 | else if (ctx.repo && !strcmp(name, "repo.path")) | ||
91 | ctx.repo->path = trim_end(value, '/'); | ||
92 | else if (ctx.repo && !prefixcmp(name, "repo.")) | ||
93 | repo_config(ctx.repo, name + 5, value); | ||
94 | else if (!strcmp(name, "root-title")) | ||
46 | ctx.cfg.root_title = xstrdup(value); | 95 | ctx.cfg.root_title = xstrdup(value); |
47 | else if (!strcmp(name, "root-desc")) | 96 | else if (!strcmp(name, "root-desc")) |
48 | ctx.cfg.root_desc = xstrdup(value); | 97 | ctx.cfg.root_desc = xstrdup(value); |
@@ -80,6 +129,8 @@ void config_cb(const char *name, const char *value) | |||
80 | ctx.cfg.noheader = atoi(value); | 129 | ctx.cfg.noheader = atoi(value); |
81 | else if (!strcmp(name, "snapshots")) | 130 | else if (!strcmp(name, "snapshots")) |
82 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 131 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
132 | else if (!strcmp(name, "enable-filter-overrides")) | ||
133 | ctx.cfg.enable_filter_overrides = atoi(value); | ||
83 | else if (!strcmp(name, "enable-index-links")) | 134 | else if (!strcmp(name, "enable-index-links")) |
84 | ctx.cfg.enable_index_links = atoi(value); | 135 | ctx.cfg.enable_index_links = atoi(value); |
85 | else if (!strcmp(name, "enable-log-filecount")) | 136 | else if (!strcmp(name, "enable-log-filecount")) |
@@ -98,6 +149,8 @@ void config_cb(const char *name, const char *value) | |||
98 | ctx.cfg.cache_root_ttl = atoi(value); | 149 | ctx.cfg.cache_root_ttl = atoi(value); |
99 | else if (!strcmp(name, "cache-repo-ttl")) | 150 | else if (!strcmp(name, "cache-repo-ttl")) |
100 | ctx.cfg.cache_repo_ttl = atoi(value); | 151 | ctx.cfg.cache_repo_ttl = atoi(value); |
152 | else if (!strcmp(name, "cache-scanrc-ttl")) | ||
153 | ctx.cfg.cache_scanrc_ttl = atoi(value); | ||
101 | else if (!strcmp(name, "cache-static-ttl")) | 154 | else if (!strcmp(name, "cache-static-ttl")) |
102 | ctx.cfg.cache_static_ttl = atoi(value); | 155 | ctx.cfg.cache_static_ttl = atoi(value); |
103 | else if (!strcmp(name, "cache-dynamic-ttl")) | 156 | else if (!strcmp(name, "cache-dynamic-ttl")) |
@@ -116,6 +169,11 @@ void config_cb(const char *name, const char *value) | |||
116 | ctx.cfg.max_repo_count = atoi(value); | 169 | ctx.cfg.max_repo_count = atoi(value); |
117 | else if (!strcmp(name, "max-commit-count")) | 170 | else if (!strcmp(name, "max-commit-count")) |
118 | ctx.cfg.max_commit_count = atoi(value); | 171 | ctx.cfg.max_commit_count = atoi(value); |
172 | else if (!strcmp(name, "scan-path")) | ||
173 | if (!ctx.cfg.nocache && ctx.cfg.cache_size) | ||
174 | process_cached_repolist(value); | ||
175 | else | ||
176 | scan_tree(value, repo_config); | ||
119 | else if (!strcmp(name, "source-filter")) | 177 | else if (!strcmp(name, "source-filter")) |
120 | ctx.cfg.source_filter = new_filter(value, 1); | 178 | ctx.cfg.source_filter = new_filter(value, 1); |
121 | else if (!strcmp(name, "summary-log")) | 179 | else if (!strcmp(name, "summary-log")) |
@@ -136,44 +194,7 @@ void config_cb(const char *name, const char *value) | |||
136 | ctx.cfg.local_time = atoi(value); | 194 | ctx.cfg.local_time = atoi(value); |
137 | else if (!prefixcmp(name, "mimetype.")) | 195 | else if (!prefixcmp(name, "mimetype.")) |
138 | add_mimetype(name + 9, value); | 196 | add_mimetype(name + 9, value); |
139 | else if (!strcmp(name, "repo.group")) | 197 | else if (!strcmp(name, "include")) |
140 | ctx.cfg.repo_group = xstrdup(value); | ||
141 | else if (!strcmp(name, "repo.url")) | ||
142 | ctx.repo = cgit_add_repo(value); | ||
143 | else if (!strcmp(name, "repo.name")) | ||
144 | ctx.repo->name = xstrdup(value); | ||
145 | else if (ctx.repo && !strcmp(name, "repo.path")) | ||
146 | ctx.repo->path = trim_end(value, '/'); | ||
147 | else if (ctx.repo && !strcmp(name, "repo.clone-url")) | ||
148 | ctx.repo->clone_url = xstrdup(value); | ||
149 | else if (ctx.repo && !strcmp(name, "repo.desc")) | ||
150 | ctx.repo->desc = xstrdup(value); | ||
151 | else if (ctx.repo && !strcmp(name, "repo.owner")) | ||
152 | ctx.repo->owner = xstrdup(value); | ||
153 | else if (ctx.repo && !strcmp(name, "repo.defbranch")) | ||
154 | ctx.repo->defbranch = xstrdup(value); | ||
155 | else if (ctx.repo && !strcmp(name, "repo.snapshots")) | ||
156 | ctx.repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); /* XXX: &? */ | ||
157 | else if (ctx.repo && !strcmp(name, "repo.enable-log-filecount")) | ||
158 | ctx.repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | ||
159 | else if (ctx.repo && !strcmp(name, "repo.enable-log-linecount")) | ||
160 | ctx.repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | ||
161 | else if (ctx.repo && !strcmp(name, "repo.max-stats")) | ||
162 | ctx.repo->max_stats = cgit_find_stats_period(value, NULL); | ||
163 | else if (ctx.repo && !strcmp(name, "repo.module-link")) | ||
164 | ctx.repo->module_link= xstrdup(value); | ||
165 | else if (ctx.repo && !strcmp(name, "repo.about-filter")) | ||
166 | ctx.repo->about_filter = new_filter(value, 0); | ||
167 | else if (ctx.repo && !strcmp(name, "repo.commit-filter")) | ||
168 |