author | Johan Herland <johan@herland.net> | 2010-06-09 23:09:35 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-06-19 08:40:24 (UTC) |
commit | 685872b770be2af643d00365d5358e46687f7385 (patch) (unidiff) | |
tree | 279a8399c3e9b189a7171df6ca009a58bf1bb8c7 /ui-shared.c | |
parent | 34c2331d2c33ea28743a2ee3e62f7337ae9887f6 (diff) | |
download | cgit-685872b770be2af643d00365d5358e46687f7385.zip cgit-685872b770be2af643d00365d5358e46687f7385.tar.gz cgit-685872b770be2af643d00365d5358e46687f7385.tar.bz2 |
ui-commit: Preserve path limit in links to commit page
This includes adding a path argument to cgit_commit_link() and updating all
its callers. The callers from within the commit page (i.e. the "commit",
"unidiff"/"side-by-side diff" and "parent" links) all preserve the path
limit of the current commit page. All other callers pass NULL (i.e. no path
limit).
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ui-shared.c b/ui-shared.c index d5c4c10..372b9e7 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -316,24 +316,25 @@ void cgit_log_link(const char *name, const char *title, const char *class, | |||
316 | html("'>"); | 316 | html("'>"); |
317 | html_txt(name); | 317 | html_txt(name); |
318 | html("</a>"); | 318 | html("</a>"); |
319 | } | 319 | } |
320 | 320 | ||
321 | void cgit_commit_link(char *name, const char *title, const char *class, | 321 | void cgit_commit_link(char *name, const char *title, const char *class, |
322 | const char *head, const char *rev, int toggle_ssdiff) | 322 | const char *head, const char *rev, const char *path, |
323 | int toggle_ssdiff) | ||
323 | { | 324 | { |
324 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { | 325 | if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { |
325 | name[ctx.cfg.max_msg_len] = '\0'; | 326 | name[ctx.cfg.max_msg_len] = '\0'; |
326 | name[ctx.cfg.max_msg_len - 1] = '.'; | 327 | name[ctx.cfg.max_msg_len - 1] = '.'; |
327 | name[ctx.cfg.max_msg_len - 2] = '.'; | 328 | name[ctx.cfg.max_msg_len - 2] = '.'; |
328 | name[ctx.cfg.max_msg_len - 3] = '.'; | 329 | name[ctx.cfg.max_msg_len - 3] = '.'; |
329 | } | 330 | } |
330 | 331 | ||
331 | char *delim; | 332 | char *delim; |
332 | 333 | ||
333 | delim = repolink(title, class, "commit", head, NULL); | 334 | delim = repolink(title, class, "commit", head, path); |
334 | if (rev && strcmp(rev, ctx.qry.head)) { | 335 | if (rev && strcmp(rev, ctx.qry.head)) { |
335 | html(delim); | 336 | html(delim); |
336 | html("id="); | 337 | html("id="); |
337 | html_url_arg(rev); | 338 | html_url_arg(rev); |
338 | delim = "&"; | 339 | delim = "&"; |
339 | } | 340 | } |
@@ -463,13 +464,13 @@ void cgit_object_link(struct object *obj) | |||
463 | 464 | ||
464 | fullrev = sha1_to_hex(obj->sha1); | 465 | fullrev = sha1_to_hex(obj->sha1); |
465 | shortrev = xstrdup(fullrev); | 466 | shortrev = xstrdup(fullrev); |
466 | shortrev[10] = '\0'; | 467 | shortrev[10] = '\0'; |
467 | if (obj->type == OBJ_COMMIT) { | 468 | if (obj->type == OBJ_COMMIT) { |
468 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, | 469 | cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, |
469 | ctx.qry.head, fullrev, 0); | 470 | ctx.qry.head, fullrev, NULL, 0); |
470 | return; | 471 | return; |
471 | } else if (obj->type == OBJ_TREE) | 472 | } else if (obj->type == OBJ_TREE) |
472 | page = "tree"; | 473 | page = "tree"; |
473 | else if (obj->type == OBJ_TAG) | 474 | else if (obj->type == OBJ_TAG) |
474 | page = "tag"; | 475 | page = "tag"; |
475 | else | 476 | else |
@@ -790,13 +791,13 @@ void cgit_print_pageheader(struct cgit_context *ctx) | |||
790 | ctx->qry.sha1, NULL); | 791 | ctx->qry.sha1, NULL); |
791 | cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, | 792 | cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head, |
792 | NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg); | 793 | NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg); |
793 | cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, | 794 | cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, |
794 | ctx->qry.sha1, NULL); | 795 | ctx->qry.sha1, NULL); |
795 | cgit_commit_link("commit", NULL, hc(ctx, "commit"), | 796 | cgit_commit_link("commit", NULL, hc(ctx, "commit"), |
796 | ctx->qry.head, ctx->qry.sha1, 0); | 797 | ctx->qry.head, ctx->qry.sha1, NULL, 0); |
797 | cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, | 798 | cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, |
798 | ctx->qry.sha1, ctx->qry.sha2, NULL, 0); | 799 | ctx->qry.sha1, ctx->qry.sha2, NULL, 0); |
799 | if (ctx->repo->max_stats) | 800 | if (ctx->repo->max_stats) |
800 | cgit_stats_link("stats", NULL, hc(ctx, "stats"), | 801 | cgit_stats_link("stats", NULL, hc(ctx, "stats"), |
801 | ctx->qry.head, NULL); | 802 | ctx->qry.head, NULL); |
802 | if (ctx->repo->readme) | 803 | if (ctx->repo->readme) |