summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Side-by-side diff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 4049a2b..08ea003 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -319,3 +319,3 @@ void cgit_log_link(char *name, char *title, char *class, char *head,
void cgit_commit_link(char *name, char *title, char *class, char *head,
- char *rev)
+ char *rev, int toggle_ssdiff)
{
@@ -327,3 +327,19 @@ void cgit_commit_link(char *name, char *title, char *class, char *head,
}
- reporevlink("commit", name, title, class, head, rev, NULL);
+
+ char *delim;
+
+ delim = repolink(title, class, "commit", head, NULL);
+ if (rev && strcmp(rev, ctx.qry.head)) {
+ html(delim);
+ html("id=");
+ html_url_arg(rev);
+ delim = "&";
+ }
+ if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
+ html(delim);
+ html("ss=1");
+ }
+ html("'>");
+ html_txt(name);
+ html("</a>");
}
@@ -343,3 +359,4 @@ void cgit_snapshot_link(char *name, char *title, char *class, char *head,
void cgit_diff_link(char *name, char *title, char *class, char *head,
- char *new_rev, char *old_rev, char *path)
+ char *new_rev, char *old_rev, char *path,
+ int toggle_ssdiff)
{
@@ -358,2 +375,7 @@ void cgit_diff_link(char *name, char *title, char *class, char *head,
html_url_arg(old_rev);
+ delim = "&amp;";
+ }
+ if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
+ html(delim);
+ html("ss=1");
}
@@ -385,3 +407,3 @@ void cgit_object_link(struct object *obj)
cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
- ctx.qry.head, fullrev);
+ ctx.qry.head, fullrev, 0);
return;
@@ -697,5 +719,5 @@ void cgit_print_pageheader(struct cgit_context *ctx)
cgit_commit_link("commit", NULL, hc(cmd, "commit"),
- ctx->qry.head, ctx->qry.sha1);
+ ctx->qry.head, ctx->qry.sha1, 0);
cgit_diff_link("diff", NULL, hc(cmd, "diff"), ctx->qry.head,
- ctx->qry.sha1, ctx->qry.sha2, NULL);
+ ctx->qry.sha1, ctx->qry.sha2, NULL, 0);
if (ctx->repo->max_stats)
@@ -762,4 +784,10 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
const struct cgit_snapshot_format* f;
+ char *prefix;
char *filename;
+ unsigned char sha1[20];
+ if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
+ (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
+ hex++;
+ prefix = xstrdup(fmt("%s-%s", cgit_repobasename(repo), hex));
for (f = cgit_snapshot_formats; f->suffix; f++) {
@@ -767,4 +795,3 @@ void cgit_print_snapshot_links(const char *repo, const char *head,
continue;
- filename = fmt("%s-%s%s", cgit_repobasename(repo), hex,
- f->suffix);
+ filename = fmt("%s%s", prefix, f->suffix);
cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename);