summaryrefslogtreecommitdiffabout
authorJohan Herland <johan@herland.net>2010-06-09 23:09:35 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-06-19 08:40:24 (UTC)
commit685872b770be2af643d00365d5358e46687f7385 (patch) (side-by-side diff)
tree279a8399c3e9b189a7171df6ca009a58bf1bb8c7
parent34c2331d2c33ea28743a2ee3e62f7337ae9887f6 (diff)
downloadcgit-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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-commit.c9
-rw-r--r--ui-log.c4
-rw-r--r--ui-refs.c2
-rw-r--r--ui-shared.c9
-rw-r--r--ui-shared.h3
5 files changed, 15 insertions, 12 deletions
diff --git a/ui-commit.c b/ui-commit.c
index 1793921..2d98ed9 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -55,20 +55,20 @@ void cgit_print_commit(char *hex, const char *prefix)
}
html("</td><td class='right'>");
cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>commit</th><td colspan='2' class='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(" (");
cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
html(") (");
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
- 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("<tr><th>tree</th><td colspan='2' class='sha1'>");
tmp = xstrdup(hex);
cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
ctx.qry.head, tmp, NULL);
if (prefix) {
@@ -84,13 +84,14 @@ void cgit_print_commit(char *hex, const char *prefix)
html("</td></tr>");
continue;
}
html("<tr><th>parent</th>"
"<td colspan='2' class='sha1'>");
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(" (");
cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
sha1_to_hex(p->item->object.sha1), prefix, 0);
html(")</td></tr>");
parents++;
}
diff --git a/ui-log.c b/ui-log.c
index 0947604..282eca3 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -63,13 +63,13 @@ void show_commit_decorations(struct commit *commit)
sha1_to_hex(commit->object.sha1), NULL,
0, NULL, NULL, ctx.qry.showmsg);
}
else {
strncpy(buf, deco->name, sizeof(buf) - 1);
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;
}
}
void print_commit(struct commit *commit)
@@ -86,13 +86,13 @@ void print_commit(struct commit *commit)
html_link_open(tmp, NULL, NULL);
cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE);
html_link_close();
htmlf("</td><td%s>",
ctx.qry.showmsg ? " class='logsubject'" : "");
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);
html("</td><td>");
html_txt(info->author);
if (ctx.repo->enable_log_filecount) {
files = 0;
add_lines = 0;
diff --git a/ui-refs.c b/ui-refs.c
index 98738db..94ff6be 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -71,13 +71,13 @@ static int print_branch(struct refinfo *ref)
html("<tr><td>");
cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL,
ctx.qry.showmsg);
html("</td><td>");
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_txt(info->author);
html("</td><td colspan='2'>");
cgit_print_age(info->commit->date, -1, NULL);
} else {
html("</td><td></td><td>");
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,
html("'>");
html_txt(name);
html("</a>");
}
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) {
name[ctx.cfg.max_msg_len] = '\0';
name[ctx.cfg.max_msg_len - 1] = '.';
name[ctx.cfg.max_msg_len - 2] = '.';
name[ctx.cfg.max_msg_len - 3] = '.';
}
char *delim;
- delim = repolink(title, class, "commit", head, NULL);
+ delim = repolink(title, class, "commit", head, path);
if (rev && strcmp(rev, ctx.qry.head)) {
html(delim);
html("id=");
html_url_arg(rev);
delim = "&amp;";
}
@@ -463,13 +464,13 @@ void cgit_object_link(struct object *obj)
fullrev = sha1_to_hex(obj->sha1);
shortrev = xstrdup(fullrev);
shortrev[10] = '\0';
if (obj->type == OBJ_COMMIT) {
cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
- ctx.qry.head, fullrev, 0);
+ ctx.qry.head, fullrev, NULL, 0);
return;
} else if (obj->type == OBJ_TREE)
page = "tree";
else if (obj->type == OBJ_TAG)
page = "tag";
else
@@ -790,13 +791,13 @@ void cgit_print_pageheader(struct cgit_context *ctx)
ctx->qry.sha1, NULL);
cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head,
NULL, NULL, 0, NULL, NULL, ctx->qry.showmsg);
cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
ctx->qry.sha1, NULL);
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,
ctx->qry.sha1, ctx->qry.sha2, NULL, 0);
if (ctx->repo->max_stats)
cgit_stats_link("stats", NULL, hc(ctx, "stats"),
ctx->qry.head, NULL);
if (ctx->repo->readme)
diff --git a/ui-shared.h b/ui-shared.h
index c0e5c55..3cc1258 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -26,13 +26,14 @@ extern void cgit_plain_link(const char *name, const char *title,
extern void cgit_log_link(const char *name, const char *title,
const char *class, const char *head, const char *rev,
const char *path, int ofs, const char *grep,
const char *pattern, int showmsg);
extern void cgit_commit_link(char *name, const char *title,
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,
const char *class, const char *head,
const char *rev, const char *path);
extern void cgit_refs_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);