-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 7 | ||||
-rw-r--r-- | scan-tree.c | 4 |
4 files changed, 14 insertions, 0 deletions
@@ -76,96 +76,98 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
76 | } else if (ctx.cfg.enable_filter_overrides) { | 76 | } else if (ctx.cfg.enable_filter_overrides) { |
77 | if (!strcmp(name, "about-filter")) | 77 | if (!strcmp(name, "about-filter")) |
78 | repo->about_filter = new_filter(value, 0); | 78 | repo->about_filter = new_filter(value, 0); |
79 | else if (!strcmp(name, "commit-filter")) | 79 | else if (!strcmp(name, "commit-filter")) |
80 | repo->commit_filter = new_filter(value, 0); | 80 | repo->commit_filter = new_filter(value, 0); |
81 | else if (!strcmp(name, "source-filter")) | 81 | else if (!strcmp(name, "source-filter")) |
82 | repo->source_filter = new_filter(value, 1); | 82 | repo->source_filter = new_filter(value, 1); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | void config_cb(const char *name, const char *value) | 86 | void config_cb(const char *name, const char *value) |
87 | { | 87 | { |
88 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) | 88 | if (!strcmp(name, "section") || !strcmp(name, "repo.group")) |
89 | ctx.cfg.section = xstrdup(value); | 89 | ctx.cfg.section = xstrdup(value); |
90 | else if (!strcmp(name, "repo.url")) | 90 | else if (!strcmp(name, "repo.url")) |
91 | ctx.repo = cgit_add_repo(value); | 91 | ctx.repo = cgit_add_repo(value); |
92 | else if (ctx.repo && !strcmp(name, "repo.path")) | 92 | else if (ctx.repo && !strcmp(name, "repo.path")) |
93 | ctx.repo->path = trim_end(value, '/'); | 93 | ctx.repo->path = trim_end(value, '/'); |
94 | else if (ctx.repo && !prefixcmp(name, "repo.")) | 94 | else if (ctx.repo && !prefixcmp(name, "repo.")) |
95 | repo_config(ctx.repo, name + 5, value); | 95 | repo_config(ctx.repo, name + 5, value); |
96 | else if (!strcmp(name, "readme")) | 96 | else if (!strcmp(name, "readme")) |
97 | ctx.cfg.readme = xstrdup(value); | 97 | ctx.cfg.readme = xstrdup(value); |
98 | else if (!strcmp(name, "root-title")) | 98 | else if (!strcmp(name, "root-title")) |
99 | ctx.cfg.root_title = xstrdup(value); | 99 | ctx.cfg.root_title = xstrdup(value); |
100 | else if (!strcmp(name, "root-desc")) | 100 | else if (!strcmp(name, "root-desc")) |
101 | ctx.cfg.root_desc = xstrdup(value); | 101 | ctx.cfg.root_desc = xstrdup(value); |
102 | else if (!strcmp(name, "root-readme")) | 102 | else if (!strcmp(name, "root-readme")) |
103 | ctx.cfg.root_readme = xstrdup(value); | 103 | ctx.cfg.root_readme = xstrdup(value); |
104 | else if (!strcmp(name, "css")) | 104 | else if (!strcmp(name, "css")) |
105 | ctx.cfg.css = xstrdup(value); | 105 | ctx.cfg.css = xstrdup(value); |
106 | else if (!strcmp(name, "favicon")) | 106 | else if (!strcmp(name, "favicon")) |
107 | ctx.cfg.favicon = xstrdup(value); | 107 | ctx.cfg.favicon = xstrdup(value); |
108 | else if (!strcmp(name, "footer")) | 108 | else if (!strcmp(name, "footer")) |
109 | ctx.cfg.footer = xstrdup(value); | 109 | ctx.cfg.footer = xstrdup(value); |
110 | else if (!strcmp(name, "head-include")) | 110 | else if (!strcmp(name, "head-include")) |
111 | ctx.cfg.head_include = xstrdup(value); | 111 | ctx.cfg.head_include = xstrdup(value); |
112 | else if (!strcmp(name, "header")) | 112 | else if (!strcmp(name, "header")) |
113 | ctx.cfg.header = xstrdup(value); | 113 | ctx.cfg.header = xstrdup(value); |
114 | else if (!strcmp(name, "logo")) | 114 | else if (!strcmp(name, "logo")) |
115 | ctx.cfg.logo = xstrdup(value); | 115 | ctx.cfg.logo = xstrdup(value); |
116 | else if (!strcmp(name, "index-header")) | 116 | else if (!strcmp(name, "index-header")) |
117 | ctx.cfg.index_header = xstrdup(value); | 117 | ctx.cfg.index_header = xstrdup(value); |
118 | else if (!strcmp(name, "index-info")) | 118 | else if (!strcmp(name, "index-info")) |
119 | ctx.cfg.index_info = xstrdup(value); | 119 | ctx.cfg.index_info = xstrdup(value); |
120 | else if (!strcmp(name, "logo-link")) | 120 | else if (!strcmp(name, "logo-link")) |
121 | ctx.cfg.logo_link = xstrdup(value); | 121 | ctx.cfg.logo_link = xstrdup(value); |
122 | else if (!strcmp(name, "module-link")) | 122 | else if (!strcmp(name, "module-link")) |
123 | ctx.cfg.module_link = xstrdup(value); | 123 | ctx.cfg.module_link = xstrdup(value); |
124 | else if (!strcmp(name, "strict-export")) | ||
125 | ctx.cfg.strict_export = xstrdup(value); | ||
124 | else if (!strcmp(name, "virtual-root")) { | 126 | else if (!strcmp(name, "virtual-root")) { |
125 | ctx.cfg.virtual_root = trim_end(value, '/'); | 127 | ctx.cfg.virtual_root = trim_end(value, '/'); |
126 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 128 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
127 | ctx.cfg.virtual_root = ""; | 129 | ctx.cfg.virtual_root = ""; |
128 | } else if (!strcmp(name, "nocache")) | 130 | } else if (!strcmp(name, "nocache")) |
129 | ctx.cfg.nocache = atoi(value); | 131 | ctx.cfg.nocache = atoi(value); |
130 | else if (!strcmp(name, "noplainemail")) | 132 | else if (!strcmp(name, "noplainemail")) |
131 | ctx.cfg.noplainemail = atoi(value); | 133 | ctx.cfg.noplainemail = atoi(value); |
132 | else if (!strcmp(name, "noheader")) | 134 | else if (!strcmp(name, "noheader")) |
133 | ctx.cfg.noheader = atoi(value); | 135 | ctx.cfg.noheader = atoi(value); |
134 | else if (!strcmp(name, "snapshots")) | 136 | else if (!strcmp(name, "snapshots")) |
135 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 137 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
136 | else if (!strcmp(name, "enable-filter-overrides")) | 138 | else if (!strcmp(name, "enable-filter-overrides")) |
137 | ctx.cfg.enable_filter_overrides = atoi(value); | 139 | ctx.cfg.enable_filter_overrides = atoi(value); |
138 | else if (!strcmp(name, "enable-gitweb-owner")) | 140 | else if (!strcmp(name, "enable-gitweb-owner")) |
139 | ctx.cfg.enable_gitweb_owner = atoi(value); | 141 | ctx.cfg.enable_gitweb_owner = atoi(value); |
140 | else if (!strcmp(name, "enable-index-links")) | 142 | else if (!strcmp(name, "enable-index-links")) |
141 | ctx.cfg.enable_index_links = atoi(value); | 143 | ctx.cfg.enable_index_links = atoi(value); |
142 | else if (!strcmp(name, "enable-log-filecount")) | 144 | else if (!strcmp(name, "enable-log-filecount")) |
143 | ctx.cfg.enable_log_filecount = atoi(value); | 145 | ctx.cfg.enable_log_filecount = atoi(value); |
144 | else if (!strcmp(name, "enable-log-linecount")) | 146 | else if (!strcmp(name, "enable-log-linecount")) |
145 | ctx.cfg.enable_log_linecount = atoi(value); | 147 | ctx.cfg.enable_log_linecount = atoi(value); |
146 | else if (!strcmp(name, "enable-remote-branches")) | 148 | else if (!strcmp(name, "enable-remote-branches")) |
147 | ctx.cfg.enable_remote_branches = atoi(value); | 149 | ctx.cfg.enable_remote_branches = atoi(value); |
148 | else if (!strcmp(name, "enable-subject-links")) | 150 | else if (!strcmp(name, "enable-subject-links")) |
149 | ctx.cfg.enable_subject_links = atoi(value); | 151 | ctx.cfg.enable_subject_links = atoi(value); |
150 | else if (!strcmp(name, "enable-tree-linenumbers")) | 152 | else if (!strcmp(name, "enable-tree-linenumbers")) |
151 | ctx.cfg.enable_tree_linenumbers = atoi(value); | 153 | ctx.cfg.enable_tree_linenumbers = atoi(value); |
152 | else if (!strcmp(name, "max-stats")) | 154 | else if (!strcmp(name, "max-stats")) |
153 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); | 155 | ctx.cfg.max_stats = cgit_find_stats_period(value, NULL); |
154 | else if (!strcmp(name, "cache-size")) | 156 | else if (!strcmp(name, "cache-size")) |
155 | ctx.cfg.cache_size = atoi(value); | 157 | ctx.cfg.cache_size = atoi(value); |
156 | else if (!strcmp(name, "cache-root")) | 158 | else if (!strcmp(name, "cache-root")) |
157 | ctx.cfg.cache_root = xstrdup(expand_macros(value)); | 159 | ctx.cfg.cache_root = xstrdup(expand_macros(value)); |
158 | else if (!strcmp(name, "cache-root-ttl")) | 160 | else if (!strcmp(name, "cache-root-ttl")) |
159 | ctx.cfg.cache_root_ttl = atoi(value); | 161 | ctx.cfg.cache_root_ttl = atoi(value); |
160 | else if (!strcmp(name, "cache-repo-ttl")) | 162 | else if (!strcmp(name, "cache-repo-ttl")) |
161 | ctx.cfg.cache_repo_ttl = atoi(value); | 163 | ctx.cfg.cache_repo_ttl = atoi(value); |
162 | else if (!strcmp(name, "cache-scanrc-ttl")) | 164 | else if (!strcmp(name, "cache-scanrc-ttl")) |
163 | ctx.cfg.cache_scanrc_ttl = atoi(value); | 165 | ctx.cfg.cache_scanrc_ttl = atoi(value); |
164 | else if (!strcmp(name, "cache-static-ttl")) | 166 | else if (!strcmp(name, "cache-static-ttl")) |
165 | ctx.cfg.cache_static_ttl = atoi(value); | 167 | ctx.cfg.cache_static_ttl = atoi(value); |
166 | else if (!strcmp(name, "cache-dynamic-ttl")) | 168 | else if (!strcmp(name, "cache-dynamic-ttl")) |
167 | ctx.cfg.cache_dynamic_ttl = atoi(value); | 169 | ctx.cfg.cache_dynamic_ttl = atoi(value); |
168 | else if (!strcmp(name, "about-filter")) | 170 | else if (!strcmp(name, "about-filter")) |
169 | ctx.cfg.about_filter = new_filter(value, 0); | 171 | ctx.cfg.about_filter = new_filter(value, 0); |
170 | else if (!strcmp(name, "commit-filter")) | 172 | else if (!strcmp(name, "commit-filter")) |
171 | ctx.cfg.commit_filter = new_filter(value, 0); | 173 | ctx.cfg.commit_filter = new_filter(value, 0); |
@@ -131,96 +131,97 @@ struct cgit_query { | |||
131 | int has_sha1; | 131 | int has_sha1; |
132 | char *raw; | 132 | char *raw; |
133 | char *repo; | 133 | char *repo; |
134 | char *page; | 134 | char *page; |
135 | char *search; | 135 | char *search; |
136 | char *grep; | 136 | char *grep; |
137 | char *head; | 137 | char *head; |
138 | char *sha1; | 138 | char *sha1; |
139 | char *sha2; | 139 | char *sha2; |
140 | char *path; | 140 | char *path; |
141 | char *name; | 141 | char *name; |
142 | char *mimetype; | 142 | char *mimetype; |
143 | char *url; | 143 | char *url; |
144 | char *period; | 144 | char *period; |
145 | int ofs; | 145 | int ofs; |
146 | int nohead; | 146 | int nohead; |
147 | char *sort; | 147 | char *sort; |
148 | int showmsg; | 148 | int showmsg; |
149 | int ssdiff; | 149 | int ssdiff; |
150 | int show_all; | 150 | int show_all; |
151 | int context; | 151 | int context; |
152 | int ignorews; | 152 | int ignorews; |
153 | char *vpath; | 153 | char *vpath; |
154 | }; | 154 | }; |
155 | 155 | ||
156 | struct cgit_config { | 156 | struct cgit_config { |
157 | char *agefile; | 157 | char *agefile; |
158 | char *cache_root; | 158 | char *cache_root; |
159 | char *clone_prefix; | 159 | char *clone_prefix; |
160 | char *css; | 160 | char *css; |
161 | char *favicon; | 161 | char *favicon; |
162 | char *footer; | 162 | char *footer; |
163 | char *head_include; | 163 | char *head_include; |
164 | char *header; | 164 | char *header; |
165 | char *index_header; | 165 | char *index_header; |
166 | char *index_info; | 166 | char *index_info; |
167 | char *logo; | 167 | char *logo; |
168 | char *logo_link; | 168 | char *logo_link; |
169 | char *module_link; | 169 | char *module_link; |
170 | char *project_list; | 170 | char *project_list; |
171 | char *readme; | 171 | char *readme; |
172 | char *robots; | 172 | char *robots; |
173 | char *root_title; | 173 | char *root_title; |
174 | char *root_desc; | 174 | char *root_desc; |
175 | char *root_readme; | 175 | char *root_readme; |
176 | char *script_name; | 176 | char *script_name; |
177 | char *section; | 177 | char *section; |
178 | char *virtual_root; | 178 | char *virtual_root; |
179 | char *strict_export; | ||
179 | int cache_size; | 180 | int cache_size; |
180 | int cache_dynamic_ttl; | 181 | int cache_dynamic_ttl; |
181 | int cache_max_create_time; | 182 | int cache_max_create_time; |
182 | int cache_repo_ttl; | 183 | int cache_repo_ttl; |
183 | int cache_root_ttl; | 184 | int cache_root_ttl; |
184 | int cache_scanrc_ttl; | 185 | int cache_scanrc_ttl; |
185 | int cache_static_ttl; | 186 | int cache_static_ttl; |
186 | int embedded; | 187 | int embedded; |
187 | int enable_filter_overrides; | 188 | int enable_filter_overrides; |
188 | int enable_gitweb_owner; | 189 | int enable_gitweb_owner; |
189 | int enable_index_links; | 190 | int enable_index_links; |
190 | int enable_log_filecount; | 191 | int enable_log_filecount; |
191 | int enable_log_linecount; | 192 | int enable_log_linecount; |
192 | int enable_remote_branches; | 193 | int enable_remote_branches; |
193 | int enable_subject_links; | 194 | int enable_subject_links; |
194 | int enable_tree_linenumbers; | 195 | int enable_tree_linenumbers; |
195 | int local_time; | 196 | int local_time; |
196 | int max_atom_items; | 197 | int max_atom_items; |
197 | int max_repo_count; | 198 | int max_repo_count; |
198 | int max_commit_count; | 199 | int max_commit_count; |
199 | int max_lock_attempts; | 200 | int max_lock_attempts; |
200 | int max_msg_len; | 201 | int max_msg_len; |
201 | int max_repodesc_len; | 202 | int max_repodesc_len; |
202 | int max_blob_size; | 203 | int max_blob_size; |
203 | int max_stats; | 204 | int max_stats; |
204 | int nocache; | 205 | int nocache; |
205 | int noplainemail; | 206 | int noplainemail; |
206 | int noheader; | 207 | int noheader; |
207 | int renamelimit; | 208 | int renamelimit; |
208 | int remove_suffix; | 209 | int remove_suffix; |
209 | int section_from_path; | 210 | int section_from_path; |
210 | int snapshots; | 211 | int snapshots; |
211 | int summary_branches; | 212 | int summary_branches; |
212 | int summary_log; | 213 | int summary_log; |
213 | int summary_tags; | 214 | int summary_tags; |
214 | int ssdiff; | 215 | int ssdiff; |
215 | struct string_list mimetypes; | 216 | struct string_list mimetypes; |
216 | struct cgit_filter *about_filter; | 217 | struct cgit_filter *about_filter; |
217 | struct cgit_filter *commit_filter; | 218 | struct cgit_filter *commit_filter; |
218 | struct cgit_filter *source_filter; | 219 | struct cgit_filter *source_filter; |
219 | }; | 220 | }; |
220 | 221 | ||
221 | struct cgit_page { | 222 | struct cgit_page { |
222 | time_t modified; | 223 | time_t modified; |
223 | time_t expires; | 224 | time_t expires; |
224 | size_t size; | 225 | size_t size; |
225 | char *mimetype; | 226 | char *mimetype; |
226 | char *charset; | 227 | char *charset; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index ce78d41..75b6584 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -272,96 +272,103 @@ root-title:: | |||
272 | scan-path:: | 272 | scan-path:: |
273 | A path which will be scanned for repositories. If caching is enabled, | 273 | A path which will be scanned for repositories. If caching is enabled, |
274 | the result will be cached as a cgitrc include-file in the cache | 274 | the result will be cached as a cgitrc include-file in the cache |
275 | directory. If project-list has been defined prior to scan-path, | 275 | directory. If project-list has been defined prior to scan-path, |
276 | scan-path loads only the directories listed in the file pointed to by | 276 | scan-path loads only the directories listed in the file pointed to by |
277 | project-list. Default value: none. See also: cache-scanrc-ttl, | 277 | project-list. Default value: none. See also: cache-scanrc-ttl, |
278 | project-list. | 278 | project-list. |
279 | 279 | ||
280 | section:: | 280 | section:: |
281 | The name of the current repository section - all repositories defined | 281 | The name of the current repository section - all repositories defined |
282 | after this option will inherit the current section name. Default value: | 282 | after this option will inherit the current section name. Default value: |
283 | none. | 283 | none. |
284 | 284 | ||
285 | section-from-path:: | 285 | section-from-path:: |
286 | A number which, if specified before scan-path, specifies how many | 286 | A number which, if specified before scan-path, specifies how many |
287 | path elements from each repo path to use as a default section name. | 287 | path elements from each repo path to use as a default section name. |
288 | If negative, cgit will discard the specified number of path elements | 288 | If negative, cgit will discard the specified number of path elements |
289 | above the repo directory. Default value: 0. | 289 | above the repo directory. Default value: 0. |
290 | 290 | ||
291 | side-by-side-diffs:: | 291 | side-by-side-diffs:: |
292 | If set to "1" shows side-by-side diffs instead of unidiffs per | 292 | If set to "1" shows side-by-side diffs instead of unidiffs per |
293 | default. Default value: "0". | 293 | default. Default value: "0". |
294 | 294 | ||
295 | snapshots:: | 295 | snapshots:: |
296 | Text which specifies the default set of snapshot formats generated by | 296 | Text which specifies the default set of snapshot formats generated by |
297 | cgit. The value is a space-separated list of zero or more of the | 297 | cgit. The value is a space-separated list of zero or more of the |
298 | values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none. | 298 | values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none. |
299 | 299 | ||
300 | source-filter:: | 300 | source-filter:: |
301 | Specifies a command which will be invoked to format plaintext blobs | 301 | Specifies a command which will be invoked to format plaintext blobs |
302 | in the tree view. The command will get the blob content on its STDIN | 302 | in the tree view. The command will get the blob content on its STDIN |
303 | and the name of the blob as its only command line argument. The STDOUT | 303 | and the name of the blob as its only command line argument. The STDOUT |
304 | from the command will be included verbatim as the blob contents, i.e. | 304 | from the command will be included verbatim as the blob contents, i.e. |
305 | this can be used to implement e.g. syntax highlighting. Default value: | 305 | this can be used to implement e.g. syntax highlighting. Default value: |
306 | none. | 306 | none. |
307 | 307 | ||
308 | summary-branches:: | 308 | summary-branches:: |
309 | Specifies the number of branches to display in the repository "summary" | 309 | Specifies the number of branches to display in the repository "summary" |
310 | view. Default value: "10". | 310 | view. Default value: "10". |
311 | 311 | ||
312 | summary-log:: | 312 | summary-log:: |
313 | Specifies the number of log entries to display in the repository | 313 | Specifies the number of log entries to display in the repository |
314 | "summary" view. Default value: "10". | 314 | "summary" view. Default value: "10". |
315 | 315 | ||
316 | summary-tags:: | 316 | summary-tags:: |
317 | Specifies the number of tags to display in the repository "summary" | 317 | Specifies the number of tags to display in the repository "summary" |
318 | view. Default value: "10". | 318 | view. Default value: "10". |
319 | 319 | ||
320 | strict-export:: | ||
321 | Filename which, if specified, needs to be present within the repository | ||
322 | for cgit to allow access to that repository. This can be used to emulate | ||
323 | gitweb's EXPORT_OK and STRICT_EXPORT functionality and limit cgit's | ||
324 | repositories to match those exported by git-daemon. This option MUST come | ||
325 | before 'scan-path'. | ||
326 | |||
320 | virtual-root:: | 327 | virtual-root:: |
321 | Url which, if specified, will be used as root for all cgit links. It | 328 | Url which, if specified, will be used as root for all cgit links. It |
322 | will also cause cgit to generate 'virtual urls', i.e. urls like | 329 | will also cause cgit to generate 'virtual urls', i.e. urls like |
323 | '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default | 330 | '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default |
324 | value: none. | 331 | value: none. |
325 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the | 332 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the |
326 | same kind of virtual urls, so this option will probably be deprecated. | 333 | same kind of virtual urls, so this option will probably be deprecated. |
327 | 334 | ||
328 | REPOSITORY SETTINGS | 335 | REPOSITORY SETTINGS |
329 | ------------------- | 336 | ------------------- |
330 | repo.about-filter:: | 337 | repo.about-filter:: |
331 | Override the default about-filter. Default value: none. See also: | 338 | Override the default about-filter. Default value: none. See also: |
332 | "enable-filter-overrides". | 339 | "enable-filter-overrides". |
333 | 340 | ||
334 | repo.clone-url:: | 341 | repo.clone-url:: |
335 | A list of space-separated urls which can be used to clone this repo. | 342 | A list of space-separated urls which can be used to clone this repo. |
336 | Default value: none. | 343 | Default value: none. |
337 | 344 | ||
338 | repo.commit-filter:: | 345 | repo.commit-filter:: |
339 | Override the default commit-filter. Default value: none. See also: | 346 | Override the default commit-filter. Default value: none. See also: |
340 | "enable-filter-overrides". | 347 | "enable-filter-overrides". |
341 | 348 | ||
342 | repo.defbranch:: | 349 | repo.defbranch:: |
343 | The name of the default branch for this repository. If no such branch | 350 | The name of the default branch for this repository. If no such branch |
344 | exists in the repository, the first branch name (when sorted) is used | 351 | exists in the repository, the first branch name (when sorted) is used |
345 | as default instead. Default value: "master". | 352 | as default instead. Default value: "master". |
346 | 353 | ||
347 | repo.desc:: | 354 | repo.desc:: |
348 | The value to show as repository description. Default value: none. | 355 | The value to show as repository description. Default value: none. |
349 | 356 | ||
350 | repo.enable-log-filecount:: | 357 | repo.enable-log-filecount:: |
351 | A flag which can be used to disable the global setting | 358 | A flag which can be used to disable the global setting |
352 | `enable-log-filecount'. Default value: none. | 359 | `enable-log-filecount'. Default value: none. |
353 | 360 | ||
354 | repo.enable-log-linecount:: | 361 | repo.enable-log-linecount:: |
355 | A flag which can be used to disable the global setting | 362 | A flag which can be used to disable the global setting |
356 | `enable-log-linecount'. Default value: none. | 363 | `enable-log-linecount'. Default value: none. |
357 | 364 | ||
358 | repo.enable-remote-branches:: | 365 | repo.enable-remote-branches:: |
359 | Flag which, when set to "1", will make cgit display remote branches | 366 | Flag which, when set to "1", will make cgit display remote branches |
360 | in the summary and refs views. Default value: <enable-remote-branches>. | 367 | in the summary and refs views. Default value: <enable-remote-branches>. |
361 | 368 | ||
362 | repo.enable-subject-links:: | 369 | repo.enable-subject-links:: |
363 | A flag which can be used to override the global setting | 370 | A flag which can be used to override the global setting |
364 | `enable-subject-links'. Default value: none. | 371 | `enable-subject-links'. Default value: none. |
365 | 372 | ||
366 | repo.max-stats:: | 373 | repo.max-stats:: |
367 | Override the default maximum statistics period. Valid values are equal | 374 | Override the default maximum statistics period. Valid values are equal |
diff --git a/scan-tree.c b/scan-tree.c index b5b50f3..a0e09ce 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -36,96 +36,100 @@ static int is_git_dir(const char *path) | |||
36 | if (stat(buf, &st)) { | 36 | if (stat(buf, &st)) { |
37 | if (errno != ENOENT) | 37 | if (errno != ENOENT) |
38 | fprintf(stderr, "Error checking path %s: %s (%d)\n", | 38 | fprintf(stderr, "Error checking path %s: %s (%d)\n", |
39 | path, strerror(errno), errno); | 39 | path, strerror(errno), errno); |
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
42 | if (!S_ISREG(st.st_mode)) | 42 | if (!S_ISREG(st.st_mode)) |
43 | return 0; | 43 | return 0; |
44 | 44 | ||
45 | return 1; | 45 | return 1; |
46 | } | 46 | } |
47 | 47 | ||
48 | struct cgit_repo *repo; | 48 | struct cgit_repo *repo; |
49 | repo_config_fn config_fn; | 49 | repo_config_fn config_fn; |
50 | char *owner; | 50 | char *owner; |
51 | 51 | ||
52 | static void repo_config(const char *name, const char *value) | 52 | static void repo_config(const char *name, const char *value) |
53 | { | 53 | { |
54 | config_fn(repo, name, value); | 54 | config_fn(repo, name, value); |
55 | } | 55 | } |
56 | 56 | ||
57 | static int git_owner_config(const char *key, const char *value, void *cb) | 57 | static int git_owner_config(const char *key, const char *value, void *cb) |
58 | { | 58 | { |
59 | if (!strcmp(key, "gitweb.owner")) | 59 | if (!strcmp(key, "gitweb.owner")) |
60 | owner = xstrdup(value); | 60 | owner = xstrdup(value); |
61 | return 0; | 61 | return 0; |
62 | } | 62 | } |
63 | 63 | ||
64 | static char *xstrrchr(char *s, char *from, int c) | 64 | static char *xstrrchr(char *s, char *from, int c) |
65 | { | 65 | { |
66 | while (from >= s && *from != c) | 66 | while (from >= s && *from != c) |
67 | from--; | 67 | from--; |
68 | return from < s ? NULL : from; | 68 | return from < s ? NULL : from; |
69 | } | 69 | } |
70 | 70 | ||
71 | static void add_repo(const char *base, const char *path, repo_config_fn fn) | 71 | static void add_repo(const char *base, const char *path, repo_config_fn fn) |
72 | { | 72 | { |
73 | struct stat st; | 73 | struct stat st; |
74 | struct passwd *pwd; | 74 | struct passwd *pwd; |
75 | char *rel, *p, *slash; | 75 | char *rel, *p, *slash; |
76 | int n; | 76 | int n; |
77 | size_t size; | 77 | size_t size; |
78 | 78 | ||
79 | if (stat(path, &st)) { | 79 | if (stat(path, &st)) { |
80 | fprintf(stderr, "Error accessing %s: %s (%d)\n", | 80 | fprintf(stderr, "Error accessing %s: %s (%d)\n", |
81 | path, strerror(errno), errno); | 81 | path, strerror(errno), errno); |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | |||
85 | if (ctx.cfg.strict_export && stat(fmt("%s/%s", path, ctx.cfg.strict_export), &st)) | ||
86 | return; | ||
87 | |||
84 | if (!stat(fmt("%s/noweb", path), &st)) | 88 | if (!stat(fmt("%s/noweb", path), &st)) |
85 | return; | 89 | return; |
86 | 90 | ||
87 | owner = NULL; | 91 | owner = NULL; |
88 | if (ctx.cfg.enable_gitweb_owner) | 92 | if (ctx.cfg.enable_gitweb_owner) |
89 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); | 93 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); |
90 | if (base == path) | 94 | if (base == path) |
91 | rel = xstrdup(fmt("%s", path)); | 95 | rel = xstrdup(fmt("%s", path)); |
92 | else | 96 | else |
93 | rel = xstrdup(fmt("%s", path + strlen(base) + 1)); | 97 | rel = xstrdup(fmt("%s", path + strlen(base) + 1)); |
94 | 98 | ||
95 | if (!strcmp(rel + strlen(rel) - 5, "/.git")) | 99 | if (!strcmp(rel + strlen(rel) - 5, "/.git")) |
96 | rel[strlen(rel) - 5] = '\0'; | 100 | rel[strlen(rel) - 5] = '\0'; |
97 | 101 | ||
98 | repo = cgit_add_repo(rel); | 102 | repo = cgit_add_repo(rel); |
99 | if (ctx.cfg.remove_suffix) | 103 | if (ctx.cfg.remove_suffix) |
100 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) | 104 | if ((p = strrchr(repo->url, '.')) && !strcmp(p, ".git")) |
101 | *p = '\0'; | 105 | *p = '\0'; |
102 | repo->name = repo->url; | 106 | repo->name = repo->url; |
103 | repo->path = xstrdup(path); | 107 | repo->path = xstrdup(path); |
104 | while (!owner) { | 108 | while (!owner) { |
105 | if ((pwd = getpwuid(st.st_uid)) == NULL) { | 109 | if ((pwd = getpwuid(st.st_uid)) == NULL) { |
106 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", | 110 | fprintf(stderr, "Error reading owner-info for %s: %s (%d)\n", |
107 | path, strerror(errno), errno); | 111 | path, strerror(errno), errno); |
108 | break; | 112 | break; |
109 | } | 113 | } |
110 | if (pwd->pw_gecos) | 114 | if (pwd->pw_gecos) |
111 | if ((p = strchr(pwd->pw_gecos, ','))) | 115 | if ((p = strchr(pwd->pw_gecos, ','))) |
112 | *p = '\0'; | 116 | *p = '\0'; |
113 | owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name); | 117 | owner = xstrdup(pwd->pw_gecos ? pwd->pw_gecos : pwd->pw_name); |
114 | } | 118 | } |
115 | repo->owner = owner; | 119 | repo->owner = owner; |
116 | 120 | ||
117 | p = fmt("%s/description", path); | 121 | p = fmt("%s/description", path); |
118 | if (!stat(p, &st)) | 122 | if (!stat(p, &st)) |
119 | readfile(p, &repo->desc, &size); | 123 | readfile(p, &repo->desc, &size); |
120 | 124 | ||
121 | if (!repo->readme) { | 125 | if (!repo->readme) { |
122 | p = fmt("%s/README.html", path); | 126 | p = fmt("%s/README.html", path); |
123 | if (!stat(p, &st)) | 127 | if (!stat(p, &st)) |
124 | repo->readme = "README.html"; | 128 | repo->readme = "README.html"; |
125 | } | 129 | } |
126 | if (ctx.cfg.section_from_path) { | 130 | if (ctx.cfg.section_from_path) { |
127 | n = ctx.cfg.section_from_path; | 131 | n = ctx.cfg.section_from_path; |
128 | if (n > 0) { | 132 | if (n > 0) { |
129 | slash = rel; | 133 | slash = rel; |
130 | while (slash && n && (slash = strchr(slash, '/'))) | 134 | while (slash && n && (slash = strchr(slash, '/'))) |
131 | n--; | 135 | n--; |