author | Felix Hanley <felix@seconddrawer.com.au> | 2010-11-08 18:41:13 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-11-08 18:41:13 (UTC) |
commit | e0c6f23789e4893781bcd5af2281d468991ccf3a (patch) (unidiff) | |
tree | 1cffe4d35b6404dd59cd0f0a314e11944e37d0f2 | |
parent | 49d09d4fd1b0cab8189cf1809a1b1241f54c2e48 (diff) | |
download | cgit-e0c6f23789e4893781bcd5af2281d468991ccf3a.zip cgit-e0c6f23789e4893781bcd5af2281d468991ccf3a.tar.gz cgit-e0c6f23789e4893781bcd5af2281d468991ccf3a.tar.bz2 |
Add `strict-export` option
This option is used to specify a filename which needs to be present in
the repositories found during `scan-path` processing. By setting this
option to 'git-daemon-export-ok', only repositories explicitly marked
for git daemon export will be included in the cgit configuration.
Signed-off-by: Felix Hanley <felix@seconddrawer.com.au>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-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
@@ -60,128 +60,130 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) | |||
60 | else if (!strcmp(name, "enable-log-filecount")) | 60 | else if (!strcmp(name, "enable-log-filecount")) |
61 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); | 61 | repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value); |
62 | else if (!strcmp(name, "enable-log-linecount")) | 62 | else if (!strcmp(name, "enable-log-linecount")) |
63 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); | 63 | repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(value); |
64 | else if (!strcmp(name, "enable-remote-branches")) | 64 | else if (!strcmp(name, "enable-remote-branches")) |
65 | repo->enable_remote_branches = atoi(value); | 65 | repo->enable_remote_branches = atoi(value); |
66 | else if (!strcmp(name, "enable-subject-links")) | 66 | else if (!strcmp(name, "enable-subject-links")) |
67 | repo->enable_subject_links = atoi(value); | 67 | repo->enable_subject_links = atoi(value); |
68 | else if (!strcmp(name, "max-stats")) | 68 | else if (!strcmp(name, "max-stats")) |
69 | repo->max_stats = cgit_find_stats_period(value, NULL); | 69 | repo->max_stats = cgit_find_stats_period(value, NULL); |
70 | else if (!strcmp(name, "module-link")) | 70 | else if (!strcmp(name, "module-link")) |
71 | repo->module_link= xstrdup(value); | 71 | repo->module_link= xstrdup(value); |
72 | else if (!strcmp(name, "section")) | 72 | else if (!strcmp(name, "section")) |
73 | repo->section = xstrdup(value); | 73 | repo->section = xstrdup(value); |
74 | else if (!strcmp(name, "readme") && value != NULL) { | 74 | else if (!strcmp(name, "readme") && value != NULL) { |
75 | repo->readme = xstrdup(value); | 75 | repo->readme = xstrdup(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); |
172 | else if (!strcmp(name, "embedded")) | 174 | else if (!strcmp(name, "embedded")) |
173 | ctx.cfg.embedded = atoi(value); | 175 | ctx.cfg.embedded = atoi(value); |
174 | else if (!strcmp(name, "max-atom-items")) | 176 | else if (!strcmp(name, "max-atom-items")) |
175 | ctx.cfg.max_atom_items = atoi(value); | 177 | ctx.cfg.max_atom_items = atoi(value); |
176 | else if (!strcmp(name, "max-message-length")) | 178 | else if (!strcmp(name, "max-message-length")) |
177 | ctx.cfg.max_msg_len = atoi(value); | 179 | ctx.cfg.max_msg_len = atoi(value); |
178 | else if (!strcmp(name, "max-repodesc-length")) | 180 | else if (!strcmp(name, "max-repodesc-length")) |
179 | ctx.cfg.max_repodesc_len = atoi(value); | 181 | ctx.cfg.max_repodesc_len = atoi(value); |
180 | else if (!strcmp(name, "max-blob-size")) | 182 | else if (!strcmp(name, "max-blob-size")) |
181 | ctx.cfg.max_blob_size = atoi(value); | 183 | ctx.cfg.max_blob_size = atoi(value); |
182 | else if (!strcmp(name, "max-repo-count")) | 184 | else if (!strcmp(name, "max-repo-count")) |
183 | ctx.cfg.max_repo_count = atoi(value); | 185 | ctx.cfg.max_repo_count = atoi(value); |
184 | else if (!strcmp(name, "max-commit-count")) | 186 | else if (!strcmp(name, "max-commit-count")) |
185 | ctx.cfg.max_commit_count = atoi(value); | 187 | ctx.cfg.max_commit_count = atoi(value); |
186 | else if (!strcmp(name, "project-list")) | 188 | else if (!strcmp(name, "project-list")) |
187 | ctx.cfg.project_list = xstrdup(expand_macros(value)); | 189 | ctx.cfg.project_list = xstrdup(expand_macros(value)); |
@@ -115,128 +115,129 @@ struct refinfo { | |||
115 | const char *refname; | 115 | const char *refname; |
116 | struct object *object; | 116 | struct object *object; |
117 | union { | 117 | union { |
118 | struct taginfo *tag; | 118 | struct taginfo *tag; |
119 | struct commitinfo *commit; | 119 | struct commitinfo *commit; |
120 | }; | 120 | }; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | struct reflist { | 123 | struct reflist { |
124 | struct refinfo **refs; | 124 | struct refinfo **refs; |
125 | int alloc; | 125 | int alloc; |
126 | int count; | 126 | int count; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | struct cgit_query { | 129 | struct cgit_query { |
130 | int has_symref; | 130 | int has_symref; |
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; |
227 | char *filename; | 228 | char *filename; |
228 | char *etag; | 229 | char *etag; |
229 | char *title; | 230 | char *title; |
230 | int status; | 231 | int status; |
231 | char *statusmsg; | 232 | char *statusmsg; |
232 | }; | 233 | }; |
233 | 234 | ||
234 | struct cgit_environment { | 235 | struct cgit_environment { |
235 | char *cgit_config; | 236 | char *cgit_config; |
236 | char *http_host; | 237 | char *http_host; |
237 | char *https; | 238 | char *https; |
238 | char *no_http; | 239 | char *no_http; |
239 | char *path_info; | 240 | char *path_info; |
240 | char *query_string; | 241 | char *query_string; |
241 | char *request_method; | 242 | char *request_method; |
242 | char *script_name; | 243 | char *script_name; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index ce78d41..75b6584 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -256,128 +256,135 @@ robots:: | |||
256 | Text used as content for the "robots" meta-tag. Default value: | 256 | Text used as content for the "robots" meta-tag. Default value: |
257 | "index, nofollow". | 257 | "index, nofollow". |
258 | 258 | ||
259 | root-desc:: | 259 | root-desc:: |
260 | Text printed below the heading on the repository index page. Default | 260 | Text printed below the heading on the repository index page. Default |
261 | value: "a fast webinterface for the git dscm". | 261 | value: "a fast webinterface for the git dscm". |
262 | 262 | ||
263 | root-readme:: | 263 | root-readme:: |
264 | The content of the file specified with this option will be included | 264 | The content of the file specified with this option will be included |
265 | verbatim below the "about" link on the repository index page. Default | 265 | verbatim below the "about" link on the repository index page. Default |
266 | value: none. | 266 | value: none. |
267 | 267 | ||
268 | root-title:: | 268 | root-title:: |
269 | Text printed as heading on the repository index page. Default value: | 269 | Text printed as heading on the repository index page. Default value: |
270 | "Git Repository Browser". | 270 | "Git Repository Browser". |
271 | 271 | ||
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 |
368 | to the values specified for the global "max-stats" setting. Default | 375 | to the values specified for the global "max-stats" setting. Default |
369 | value: none. | 376 | value: none. |
370 | 377 | ||
371 | repo.name:: | 378 | repo.name:: |
372 | The value to show as repository name. Default value: <repo.url>. | 379 | The value to show as repository name. Default value: <repo.url>. |
373 | 380 | ||
374 | repo.owner:: | 381 | repo.owner:: |
375 | A value used to identify the owner of the repository. Default value: | 382 | A value used to identify the owner of the repository. Default value: |
376 | none. | 383 | none. |
377 | 384 | ||
378 | repo.path:: | 385 | repo.path:: |
379 | An absolute path to the repository directory. For non-bare repositories | 386 | An absolute path to the repository directory. For non-bare repositories |
380 | this is the .git-directory. Default value: none. | 387 | this is the .git-directory. Default value: none. |
381 | 388 | ||
382 | repo.readme:: | 389 | repo.readme:: |
383 | A path (relative to <repo.path>) which specifies a file to include | 390 | A path (relative to <repo.path>) which specifies a file to include |
diff --git a/scan-tree.c b/scan-tree.c index b5b50f3..a0e09ce 100644 --- a/scan-tree.c +++ b/scan-tree.c | |||
@@ -20,128 +20,132 @@ static int is_git_dir(const char *path) | |||
20 | static char buf[MAX_PATH]; | 20 | static char buf[MAX_PATH]; |
21 | 21 | ||
22 | if (snprintf(buf, MAX_PATH, "%s/objects", path) >= MAX_PATH) { | 22 | if (snprintf(buf, MAX_PATH, "%s/objects", path) >= MAX_PATH) { |
23 | fprintf(stderr, "Insanely long path: %s\n", path); | 23 | fprintf(stderr, "Insanely long path: %s\n", path); |
24 | return 0; | 24 | return 0; |
25 | } | 25 | } |
26 | if (stat(buf, &st)) { | 26 | if (stat(buf, &st)) { |
27 | if (errno != ENOENT) | 27 | if (errno != ENOENT) |
28 | fprintf(stderr, "Error checking path %s: %s (%d)\n", | 28 | fprintf(stderr, "Error checking path %s: %s (%d)\n", |
29 | path, strerror(errno), errno); | 29 | path, strerror(errno), errno); |
30 | return 0; | 30 | return 0; |
31 | } | 31 | } |
32 | if (!S_ISDIR(st.st_mode)) | 32 | if (!S_ISDIR(st.st_mode)) |
33 | return 0; | 33 | return 0; |
34 | 34 | ||
35 | sprintf(buf, "%s/HEAD", path); | 35 | sprintf(buf, "%s/HEAD", 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--; |
132 | } else { | 136 | } else { |
133 | slash = rel + strlen(rel); | 137 | slash = rel + strlen(rel); |
134 | while (slash && n && (slash = xstrrchr(rel, slash, '/'))) | 138 | while (slash && n && (slash = xstrrchr(rel, slash, '/'))) |
135 | n++; | 139 | n++; |
136 | } | 140 | } |
137 | if (slash && !n) { | 141 | if (slash && !n) { |
138 | *slash = '\0'; | 142 | *slash = '\0'; |
139 | repo->section = xstrdup(rel); | 143 | repo->section = xstrdup(rel); |
140 | *slash = '/'; | 144 | *slash = '/'; |
141 | if (!prefixcmp(repo->name, repo->section)) { | 145 | if (!prefixcmp(repo->name, repo->section)) { |
142 | repo->name += strlen(repo->section); | 146 | repo->name += strlen(repo->section); |
143 | if (*repo->name == '/') | 147 | if (*repo->name == '/') |
144 | repo->name++; | 148 | repo->name++; |
145 | } | 149 | } |
146 | } | 150 | } |
147 | } | 151 | } |