|
diff --git a/cgit.c b/cgit.c index cefeddf..e2d5edb 100644 --- a/ cgit.c+++ b/ cgit.c |
|
@@ -125,104 +125,107 @@ static void querystring_cb(const char *name, const char *value) |
125 | if (!strcmp(name,"r")) { |
125 | if (!strcmp(name,"r")) { |
126 | ctx.qry.repo = xstrdup(value); |
126 | ctx.qry.repo = xstrdup(value); |
127 | ctx.repo = cgit_get_repoinfo(value); |
127 | ctx.repo = cgit_get_repoinfo(value); |
128 | } else if (!strcmp(name, "p")) { |
128 | } else if (!strcmp(name, "p")) { |
129 | ctx.qry.page = xstrdup(value); |
129 | ctx.qry.page = xstrdup(value); |
130 | } else if (!strcmp(name, "url")) { |
130 | } else if (!strcmp(name, "url")) { |
131 | cgit_parse_url(value); |
131 | cgit_parse_url(value); |
132 | } else if (!strcmp(name, "qt")) { |
132 | } else if (!strcmp(name, "qt")) { |
133 | ctx.qry.grep = xstrdup(value); |
133 | ctx.qry.grep = xstrdup(value); |
134 | } else if (!strcmp(name, "q")) { |
134 | } else if (!strcmp(name, "q")) { |
135 | ctx.qry.search = xstrdup(value); |
135 | ctx.qry.search = xstrdup(value); |
136 | } else if (!strcmp(name, "h")) { |
136 | } else if (!strcmp(name, "h")) { |
137 | ctx.qry.head = xstrdup(value); |
137 | ctx.qry.head = xstrdup(value); |
138 | ctx.qry.has_symref = 1; |
138 | ctx.qry.has_symref = 1; |
139 | } else if (!strcmp(name, "id")) { |
139 | } else if (!strcmp(name, "id")) { |
140 | ctx.qry.sha1 = xstrdup(value); |
140 | ctx.qry.sha1 = xstrdup(value); |
141 | ctx.qry.has_sha1 = 1; |
141 | ctx.qry.has_sha1 = 1; |
142 | } else if (!strcmp(name, "id2")) { |
142 | } else if (!strcmp(name, "id2")) { |
143 | ctx.qry.sha2 = xstrdup(value); |
143 | ctx.qry.sha2 = xstrdup(value); |
144 | ctx.qry.has_sha1 = 1; |
144 | ctx.qry.has_sha1 = 1; |
145 | } else if (!strcmp(name, "ofs")) { |
145 | } else if (!strcmp(name, "ofs")) { |
146 | ctx.qry.ofs = atoi(value); |
146 | ctx.qry.ofs = atoi(value); |
147 | } else if (!strcmp(name, "path")) { |
147 | } else if (!strcmp(name, "path")) { |
148 | ctx.qry.path = trim_end(value, '/'); |
148 | ctx.qry.path = trim_end(value, '/'); |
149 | } else if (!strcmp(name, "name")) { |
149 | } else if (!strcmp(name, "name")) { |
150 | ctx.qry.name = xstrdup(value); |
150 | ctx.qry.name = xstrdup(value); |
151 | } else if (!strcmp(name, "mimetype")) { |
151 | } else if (!strcmp(name, "mimetype")) { |
152 | ctx.qry.mimetype = xstrdup(value); |
152 | ctx.qry.mimetype = xstrdup(value); |
153 | } |
153 | } |
154 | } |
154 | } |
155 | |
155 | |
156 | static void prepare_context(struct cgit_context *ctx) |
156 | static void prepare_context(struct cgit_context *ctx) |
157 | { |
157 | { |
158 | memset(ctx, 0, sizeof(ctx)); |
158 | memset(ctx, 0, sizeof(ctx)); |
159 | ctx->cfg.agefile = "info/web/last-modified"; |
159 | ctx->cfg.agefile = "info/web/last-modified"; |
160 | ctx->cfg.nocache = 0; |
160 | ctx->cfg.nocache = 0; |
161 | ctx->cfg.cache_size = 0; |
161 | ctx->cfg.cache_size = 0; |
162 | ctx->cfg.cache_dynamic_ttl = 5; |
162 | ctx->cfg.cache_dynamic_ttl = 5; |
163 | ctx->cfg.cache_max_create_time = 5; |
163 | ctx->cfg.cache_max_create_time = 5; |
164 | ctx->cfg.cache_repo_ttl = 5; |
164 | ctx->cfg.cache_repo_ttl = 5; |
165 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
165 | ctx->cfg.cache_root = CGIT_CACHE_ROOT; |
166 | ctx->cfg.cache_root_ttl = 5; |
166 | ctx->cfg.cache_root_ttl = 5; |
167 | ctx->cfg.cache_static_ttl = -1; |
167 | ctx->cfg.cache_static_ttl = -1; |
168 | ctx->cfg.css = "/cgit.css"; |
168 | ctx->cfg.css = "/cgit.css"; |
169 | ctx->cfg.logo = "/git-logo.png"; |
169 | ctx->cfg.logo = "/git-logo.png"; |
170 | ctx->cfg.max_repo_count = 50; |
170 | ctx->cfg.max_repo_count = 50; |
171 | ctx->cfg.max_commit_count = 50; |
171 | ctx->cfg.max_commit_count = 50; |
172 | ctx->cfg.max_lock_attempts = 5; |
172 | ctx->cfg.max_lock_attempts = 5; |
173 | ctx->cfg.max_msg_len = 60; |
173 | ctx->cfg.max_msg_len = 80; |
174 | ctx->cfg.max_repodesc_len = 60; |
174 | ctx->cfg.max_repodesc_len = 80; |
175 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
175 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
176 | ctx->cfg.renamelimit = -1; |
176 | ctx->cfg.renamelimit = -1; |
177 | ctx->cfg.robots = "index, nofollow"; |
177 | ctx->cfg.robots = "index, nofollow"; |
178 | ctx->cfg.root_title = "Git repository browser"; |
178 | ctx->cfg.root_title = "Git repository browser"; |
179 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
179 | ctx->cfg.root_desc = "a fast webinterface for the git dscm"; |
180 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
180 | ctx->cfg.script_name = CGIT_SCRIPT_NAME; |
| |
181 | ctx->cfg.summary_branches = 10; |
| |
182 | ctx->cfg.summary_log = 10; |
| |
183 | ctx->cfg.summary_tags = 10; |
181 | ctx->page.mimetype = "text/html"; |
184 | ctx->page.mimetype = "text/html"; |
182 | ctx->page.charset = PAGE_ENCODING; |
185 | ctx->page.charset = PAGE_ENCODING; |
183 | ctx->page.filename = NULL; |
186 | ctx->page.filename = NULL; |
184 | ctx->page.modified = time(NULL); |
187 | ctx->page.modified = time(NULL); |
185 | ctx->page.expires = ctx->page.modified; |
188 | ctx->page.expires = ctx->page.modified; |
186 | } |
189 | } |
187 | |
190 | |
188 | struct refmatch { |
191 | struct refmatch { |
189 | char *req_ref; |
192 | char *req_ref; |
190 | char *first_ref; |
193 | char *first_ref; |
191 | int match; |
194 | int match; |
192 | }; |
195 | }; |
193 | |
196 | |
194 | int find_current_ref(const char *refname, const unsigned char *sha1, |
197 | int find_current_ref(const char *refname, const unsigned char *sha1, |
195 | int flags, void *cb_data) |
198 | int flags, void *cb_data) |
196 | { |
199 | { |
197 | struct refmatch *info; |
200 | struct refmatch *info; |
198 | |
201 | |
199 | info = (struct refmatch *)cb_data; |
202 | info = (struct refmatch *)cb_data; |
200 | if (!strcmp(refname, info->req_ref)) |
203 | if (!strcmp(refname, info->req_ref)) |
201 | info->match = 1; |
204 | info->match = 1; |
202 | if (!info->first_ref) |
205 | if (!info->first_ref) |
203 | info->first_ref = xstrdup(refname); |
206 | info->first_ref = xstrdup(refname); |
204 | return info->match; |
207 | return info->match; |
205 | } |
208 | } |
206 | |
209 | |
207 | char *find_default_branch(struct cgit_repo *repo) |
210 | char *find_default_branch(struct cgit_repo *repo) |
208 | { |
211 | { |
209 | struct refmatch info; |
212 | struct refmatch info; |
210 | char *ref; |
213 | char *ref; |
211 | |
214 | |
212 | info.req_ref = repo->defbranch; |
215 | info.req_ref = repo->defbranch; |
213 | info.first_ref = NULL; |
216 | info.first_ref = NULL; |
214 | info.match = 0; |
217 | info.match = 0; |
215 | for_each_branch_ref(find_current_ref, &info); |
218 | for_each_branch_ref(find_current_ref, &info); |
216 | if (info.match) |
219 | if (info.match) |
217 | ref = info.req_ref; |
220 | ref = info.req_ref; |
218 | else |
221 | else |
219 | ref = info.first_ref; |
222 | ref = info.first_ref; |
220 | if (ref) |
223 | if (ref) |
221 | ref = xstrdup(ref); |
224 | ref = xstrdup(ref); |
222 | return ref; |
225 | return ref; |
223 | } |
226 | } |
224 | |
227 | |
225 | static int prepare_repo_cmd(struct cgit_context *ctx) |
228 | static int prepare_repo_cmd(struct cgit_context *ctx) |
226 | { |
229 | { |
227 | char *tmp; |
230 | char *tmp; |
228 | unsigned char sha1[20]; |
231 | unsigned char sha1[20]; |
|