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>
This commit is contained in:
Johan Herland 2010-06-10 01:09:35 +02:00 зафіксовано Lars Hjemli
джерело 34c2331d2c
коміт 685872b770
5 змінених файлів з 15 додано та 12 видалено

@ -58,14 +58,14 @@ void cgit_print_commit(char *hex, const char *prefix)
html("</td></tr>\n"); html("</td></tr>\n");
html("<tr><th>commit</th><td colspan='2' class='sha1'>"); html("<tr><th>commit</th><td colspan='2' class='sha1'>");
tmp = sha1_to_hex(commit->object.sha1); tmp = sha1_to_hex(commit->object.sha1);
cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0); cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix, 0);
html(" ("); html(" (");
cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix); cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
html(") ("); html(") (");
if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, 1); cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
else else
cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1); cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, prefix, 1);
html(")</td></tr>\n"); html(")</td></tr>\n");
html("<tr><th>tree</th><td colspan='2' class='sha1'>"); html("<tr><th>tree</th><td colspan='2' class='sha1'>");
tmp = xstrdup(hex); tmp = xstrdup(hex);
@ -87,7 +87,8 @@ void cgit_print_commit(char *hex, const char *prefix)
html("<tr><th>parent</th>" html("<tr><th>parent</th>"
"<td colspan='2' class='sha1'>"); "<td colspan='2' class='sha1'>");
cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL,
ctx.qry.head, sha1_to_hex(p->item->object.sha1), 0); ctx.qry.head,
sha1_to_hex(p->item->object.sha1), prefix, 0);
html(" ("); html(" (");
cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
sha1_to_hex(p->item->object.sha1), prefix, 0); sha1_to_hex(p->item->object.sha1), prefix, 0);

@ -66,7 +66,7 @@ void show_commit_decorations(struct commit *commit)
else { else {
strncpy(buf, deco->name, sizeof(buf) - 1); strncpy(buf, deco->name, sizeof(buf) - 1);
cgit_commit_link(buf, NULL, "deco", ctx.qry.head, cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
sha1_to_hex(commit->object.sha1), 0); sha1_to_hex(commit->object.sha1), NULL, 0);
} }
deco = deco->next; deco = deco->next;
} }
@ -89,7 +89,7 @@ void print_commit(struct commit *commit)
htmlf("</td><td%s>", htmlf("</td><td%s>",
ctx.qry.showmsg ? " class='logsubject'" : ""); ctx.qry.showmsg ? " class='logsubject'" : "");
cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
sha1_to_hex(commit->object.sha1), 0); sha1_to_hex(commit->object.sha1), NULL, 0);
show_commit_decorations(commit); show_commit_decorations(commit);
html("</td><td>"); html("</td><td>");
html_txt(info->author); html_txt(info->author);

@ -74,7 +74,7 @@ static int print_branch(struct refinfo *ref)
html("</td><td>"); html("</td><td>");
if (ref->object->type == OBJ_COMMIT) { if (ref->object->type == OBJ_COMMIT) {
cgit_commit_link(info->subject, NULL, NULL, name, NULL, 0); cgit_commit_link(info->subject, NULL, NULL, name, NULL, NULL, 0);
html("</td><td>"); html("</td><td>");
html_txt(info->author); html_txt(info->author);
html("</td><td colspan='2'>"); html("</td><td colspan='2'>");

@ -319,7 +319,8 @@ void cgit_log_link(const char *name, const char *title, const char *class,
} }
void cgit_commit_link(char *name, const char *title, const char *class, void cgit_commit_link(char *name, const char *title, const char *class,
const char *head, const char *rev, int toggle_ssdiff) const char *head, const char *rev, const char *path,
int toggle_ssdiff)
{ {
if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) { if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
name[ctx.cfg.max_msg_len] = '\0'; name[ctx.cfg.max_msg_len] = '\0';
@ -330,7 +331,7 @@ void cgit_commit_link(char *name, const char *title, const char *class,
char *delim; char *delim;
delim = repolink(title, class, "commit", head, NULL); delim = repolink(title, class, "commit", head, path);
if (rev && strcmp(rev, ctx.qry.head)) { if (rev && strcmp(rev, ctx.qry.head)) {
html(delim); html(delim);
html("id="); html("id=");
@ -466,7 +467,7 @@ void cgit_object_link(struct object *obj)
shortrev[10] = '\0'; shortrev[10] = '\0';
if (obj->type == OBJ_COMMIT) { if (obj->type == OBJ_COMMIT) {
cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
ctx.qry.head, fullrev, 0); ctx.qry.head, fullrev, NULL, 0);
return; return;
} else if (obj->type == OBJ_TREE) } else if (obj->type == OBJ_TREE)
page = "tree"; page = "tree";
@ -793,7 +794,7 @@ void cgit_print_pageheader(struct cgit_context *ctx)
cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head, cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
ctx->qry.sha1, NULL); ctx->qry.sha1, NULL);
cgit_commit_link("commit", NULL, hc(ctx, "commit"), cgit_commit_link("commit", NULL, hc(ctx, "commit"),
ctx->qry.head, ctx->qry.sha1, 0); ctx->qry.head, ctx->qry.sha1, NULL, 0);
cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head, cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head,
ctx->qry.sha1, ctx->qry.sha2, NULL, 0); ctx->qry.sha1, ctx->qry.sha2, NULL, 0);
if (ctx->repo->max_stats) if (ctx->repo->max_stats)

@ -29,7 +29,8 @@ extern void cgit_log_link(const char *name, const char *title,
const char *pattern, int showmsg); const char *pattern, int showmsg);
extern void cgit_commit_link(char *name, const char *title, extern void cgit_commit_link(char *name, const char *title,
const char *class, const char *head, const char *class, const char *head,
const char *rev, int toggle_ssdiff); const char *rev, const char *path,
int toggle_ssdiff);
extern void cgit_patch_link(const char *name, const char *title, extern void cgit_patch_link(const char *name, const char *title,
const char *class, const char *head, const char *class, const char *head,
const char *rev, const char *path); const char *rev, const char *path);