summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c2
-rw-r--r--ui-shared.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/cgit.c b/cgit.c
index e46c00a..9305d0a 100644
--- a/cgit.c
+++ b/cgit.c
@@ -239,49 +239,49 @@ static void querystring_cb(const char *name, const char *value)
239 } else if (!strcmp(name, "path")) { 239 } else if (!strcmp(name, "path")) {
240 ctx.qry.path = trim_end(value, '/'); 240 ctx.qry.path = trim_end(value, '/');
241 } else if (!strcmp(name, "name")) { 241 } else if (!strcmp(name, "name")) {
242 ctx.qry.name = xstrdup(value); 242 ctx.qry.name = xstrdup(value);
243 } else if (!strcmp(name, "mimetype")) { 243 } else if (!strcmp(name, "mimetype")) {
244 ctx.qry.mimetype = xstrdup(value); 244 ctx.qry.mimetype = xstrdup(value);
245 } else if (!strcmp(name, "s")){ 245 } else if (!strcmp(name, "s")){
246 ctx.qry.sort = xstrdup(value); 246 ctx.qry.sort = xstrdup(value);
247 } else if (!strcmp(name, "showmsg")) { 247 } else if (!strcmp(name, "showmsg")) {
248 ctx.qry.showmsg = atoi(value); 248 ctx.qry.showmsg = atoi(value);
249 } else if (!strcmp(name, "period")) { 249 } else if (!strcmp(name, "period")) {
250 ctx.qry.period = xstrdup(value); 250 ctx.qry.period = xstrdup(value);
251 } else if (!strcmp(name, "ss")) { 251 } else if (!strcmp(name, "ss")) {
252 ctx.qry.ssdiff = atoi(value); 252 ctx.qry.ssdiff = atoi(value);
253 } 253 }
254} 254}
255 255
256char *xstrdupn(const char *str) 256char *xstrdupn(const char *str)
257{ 257{
258 return (str ? xstrdup(str) : NULL); 258 return (str ? xstrdup(str) : NULL);
259} 259}
260 260
261static void prepare_context(struct cgit_context *ctx) 261static void prepare_context(struct cgit_context *ctx)
262{ 262{
263 memset(ctx, 0, sizeof(ctx)); 263 memset(ctx, 0, sizeof(*ctx));
264 ctx->cfg.agefile = "info/web/last-modified"; 264 ctx->cfg.agefile = "info/web/last-modified";
265 ctx->cfg.nocache = 0; 265 ctx->cfg.nocache = 0;
266 ctx->cfg.cache_size = 0; 266 ctx->cfg.cache_size = 0;
267 ctx->cfg.cache_dynamic_ttl = 5; 267 ctx->cfg.cache_dynamic_ttl = 5;
268 ctx->cfg.cache_max_create_time = 5; 268 ctx->cfg.cache_max_create_time = 5;
269 ctx->cfg.cache_repo_ttl = 5; 269 ctx->cfg.cache_repo_ttl = 5;
270 ctx->cfg.cache_root = CGIT_CACHE_ROOT; 270 ctx->cfg.cache_root = CGIT_CACHE_ROOT;
271 ctx->cfg.cache_root_ttl = 5; 271 ctx->cfg.cache_root_ttl = 5;
272 ctx->cfg.cache_scanrc_ttl = 15; 272 ctx->cfg.cache_scanrc_ttl = 15;
273 ctx->cfg.cache_static_ttl = -1; 273 ctx->cfg.cache_static_ttl = -1;
274 ctx->cfg.css = "/cgit.css"; 274 ctx->cfg.css = "/cgit.css";
275 ctx->cfg.logo = "/cgit.png"; 275 ctx->cfg.logo = "/cgit.png";
276 ctx->cfg.local_time = 0; 276 ctx->cfg.local_time = 0;
277 ctx->cfg.enable_tree_linenumbers = 1; 277 ctx->cfg.enable_tree_linenumbers = 1;
278 ctx->cfg.max_repo_count = 50; 278 ctx->cfg.max_repo_count = 50;
279 ctx->cfg.max_commit_count = 50; 279 ctx->cfg.max_commit_count = 50;
280 ctx->cfg.max_lock_attempts = 5; 280 ctx->cfg.max_lock_attempts = 5;
281 ctx->cfg.max_msg_len = 80; 281 ctx->cfg.max_msg_len = 80;
282 ctx->cfg.max_repodesc_len = 80; 282 ctx->cfg.max_repodesc_len = 80;
283 ctx->cfg.max_blob_size = 0; 283 ctx->cfg.max_blob_size = 0;
284 ctx->cfg.max_stats = 0; 284 ctx->cfg.max_stats = 0;
285 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; 285 ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
286 ctx->cfg.renamelimit = -1; 286 ctx->cfg.renamelimit = -1;
287 ctx->cfg.robots = "index, nofollow"; 287 ctx->cfg.robots = "index, nofollow";
diff --git a/ui-shared.c b/ui-shared.c
index 08ea003..8827fff 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -225,49 +225,49 @@ static char *repolink(char *title, char *class, char *page, char *head,
225 html("/"); 225 html("/");
226 if (page) { 226 if (page) {
227 html_url_arg(page); 227 html_url_arg(page);
228 html("/"); 228 html("/");
229 if (path) 229 if (path)
230 html_url_arg(path); 230 html_url_arg(path);
231 } 231 }
232 delim = "&"; 232 delim = "&";
233 } 233 }
234 if (head && strcmp(head, ctx.repo->defbranch)) { 234 if (head && strcmp(head, ctx.repo->defbranch)) {
235 html(delim); 235 html(delim);
236 html("h="); 236 html("h=");
237 html_url_arg(head); 237 html_url_arg(head);
238 delim = "&"; 238 delim = "&";
239 } 239 }
240 return fmt("%s", delim); 240 return fmt("%s", delim);
241} 241}
242 242
243static void reporevlink(char *page, char *name, char *title, char *class, 243static void reporevlink(char *page, char *name, char *title, char *class,
244 char *head, char *rev, char *path) 244 char *head, char *rev, char *path)
245{ 245{
246 char *delim; 246 char *delim;
247 247
248 delim = repolink(title, class, page, head, path); 248 delim = repolink(title, class, page, head, path);
249 if (rev && strcmp(rev, ctx.qry.head)) { 249 if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) {
250 html(delim); 250 html(delim);
251 html("id="); 251 html("id=");
252 html_url_arg(rev); 252 html_url_arg(rev);
253 } 253 }
254 html("'>"); 254 html("'>");
255 html_txt(name); 255 html_txt(name);
256 html("</a>"); 256 html("</a>");
257} 257}
258 258
259void cgit_summary_link(char *name, char *title, char *class, char *head) 259void cgit_summary_link(char *name, char *title, char *class, char *head)
260{ 260{
261 reporevlink(NULL, name, title, class, head, NULL, NULL); 261 reporevlink(NULL, name, title, class, head, NULL, NULL);
262} 262}
263 263
264void cgit_tag_link(char *name, char *title, char *class, char *head, 264void cgit_tag_link(char *name, char *title, char *class, char *head,
265 char *rev) 265 char *rev)
266{ 266{
267 reporevlink("tag", name, title, class, head, rev, NULL); 267 reporevlink("tag", name, title, class, head, rev, NULL);
268} 268}
269 269
270void cgit_tree_link(char *name, char *title, char *class, char *head, 270void cgit_tree_link(char *name, char *title, char *class, char *head,
271 char *rev, char *path) 271 char *rev, char *path)
272{ 272{
273 reporevlink("tree", name, title, class, head, rev, path); 273 reporevlink("tree", name, title, class, head, rev, path);
@@ -342,49 +342,49 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
342 html("'>"); 342 html("'>");
343 html_txt(name); 343 html_txt(name);
344 html("</a>"); 344 html("</a>");
345} 345}
346 346
347void cgit_refs_link(char *name, char *title, char *class, char *head, 347void cgit_refs_link(char *name, char *title, char *class, char *head,
348 char *rev, char *path) 348 char *rev, char *path)
349{ 349{
350 reporevlink("refs", name, title, class, head, rev, path); 350 reporevlink("refs", name, title, class, head, rev, path);
351} 351}
352 352
353void cgit_snapshot_link(char *name, char *title, char *class, char *head, 353void cgit_snapshot_link(char *name, char *title, char *class, char *head,
354 char *rev, char *archivename) 354 char *rev, char *archivename)
355{ 355{
356 reporevlink("snapshot", name, title, class, head, rev, archivename); 356 reporevlink("snapshot", name, title, class, head, rev, archivename);
357} 357}
358 358
359void cgit_diff_link(char *name, char *title, char *class, char *head, 359void cgit_diff_link(char *name, char *title, char *class, char *head,
360 char *new_rev, char *old_rev, char *path, 360 char *new_rev, char *old_rev, char *path,
361 int toggle_ssdiff) 361 int toggle_ssdiff)
362{ 362{
363 char *delim; 363 char *delim;
364 364
365 delim = repolink(title, class, "diff", head, path); 365 delim = repolink(title, class, "diff", head, path);
366 if (new_rev && strcmp(new_rev, ctx.qry.head)) { 366 if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
367 html(delim); 367 html(delim);
368 html("id="); 368 html("id=");
369 html_url_arg(new_rev); 369 html_url_arg(new_rev);
370 delim = "&amp;"; 370 delim = "&amp;";
371 } 371 }
372 if (old_rev) { 372 if (old_rev) {
373 html(delim); 373 html(delim);
374 html("id2="); 374 html("id2=");
375 html_url_arg(old_rev); 375 html_url_arg(old_rev);
376 delim = "&amp;"; 376 delim = "&amp;";
377 } 377 }
378 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 378 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
379 html(delim); 379 html(delim);
380 html("ss=1"); 380 html("ss=1");
381 } 381 }
382 html("'>"); 382 html("'>");
383 html_txt(name); 383 html_txt(name);
384 html("</a>"); 384 html("</a>");
385} 385}
386 386
387void cgit_patch_link(char *name, char *title, char *class, char *head, 387void cgit_patch_link(char *name, char *title, char *class, char *head,
388 char *rev) 388 char *rev)
389{ 389{
390 reporevlink("patch", name, title, class, head, rev, NULL); 390 reporevlink("patch", name, title, class, head, rev, NULL);