mirror of
https://git.zx2c4.com/cgit
synced 2024-11-22 08:28:42 +00:00
ui-log: Simplify decoration code
The decoration code inside of git returns the decoration type, so utilize this to create the decoration spans. Additionally, use prettify_refname(...) to get the shorter name for the ref. Signed-off-by: Tim Nordell <tim.nordell@logicpd.com>
This commit is contained in:
parent
499b23979c
commit
59d8fa1a62
46
ui-log.c
46
ui-log.c
@ -65,36 +65,34 @@ void show_commit_decorations(struct commit *commit)
|
|||||||
return;
|
return;
|
||||||
html("<span class='decoration'>");
|
html("<span class='decoration'>");
|
||||||
while (deco) {
|
while (deco) {
|
||||||
if (starts_with(deco->name, "refs/heads/")) {
|
strncpy(buf, prettify_refname(deco->name), sizeof(buf) - 1);
|
||||||
strncpy(buf, deco->name + 11, sizeof(buf) - 1);
|
switch(deco->type) {
|
||||||
|
case DECORATION_NONE:
|
||||||
|
/* If the git-core doesn't recognize it,
|
||||||
|
* don't display anything. */
|
||||||
|
break;
|
||||||
|
case DECORATION_REF_LOCAL:
|
||||||
cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
|
cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
|
||||||
ctx.qry.vpath, 0, NULL, NULL,
|
ctx.qry.vpath, 0, NULL, NULL,
|
||||||
ctx.qry.showmsg, 0);
|
ctx.qry.showmsg, 0);
|
||||||
}
|
break;
|
||||||
else if (starts_with(deco->name, "tag: refs/tags/")) {
|
case DECORATION_REF_TAG:
|
||||||
strncpy(buf, deco->name + 15, sizeof(buf) - 1);
|
|
||||||
cgit_tag_link(buf, NULL, "tag-deco", buf);
|
cgit_tag_link(buf, NULL, "tag-deco", buf);
|
||||||
}
|
break;
|
||||||
else if (starts_with(deco->name, "refs/tags/")) {
|
case DECORATION_REF_REMOTE:
|
||||||
strncpy(buf, deco->name + 10, sizeof(buf) - 1);
|
|
||||||
cgit_tag_link(buf, NULL, "tag-deco", buf);
|
|
||||||
}
|
|
||||||
else if (starts_with(deco->name, "refs/remotes/")) {
|
|
||||||
if (!ctx.repo->enable_remote_branches)
|
if (!ctx.repo->enable_remote_branches)
|
||||||
goto next;
|
break;
|
||||||
strncpy(buf, deco->name + 13, sizeof(buf) - 1);
|
|
||||||
cgit_log_link(buf, NULL, "remote-deco", NULL,
|
cgit_log_link(buf, NULL, "remote-deco", NULL,
|
||||||
oid_to_hex(&commit->object.oid),
|
oid_to_hex(&commit->object.oid),
|
||||||
ctx.qry.vpath, 0, NULL, NULL,
|
ctx.qry.vpath, 0, NULL, NULL,
|
||||||
ctx.qry.showmsg, 0);
|
ctx.qry.showmsg, 0);
|
||||||
}
|
break;
|
||||||
else {
|
default:
|
||||||
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,
|
||||||
oid_to_hex(&commit->object.oid),
|
oid_to_hex(&commit->object.oid),
|
||||||
ctx.qry.vpath);
|
ctx.qry.vpath);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
next:
|
|
||||||
deco = deco->next;
|
deco = deco->next;
|
||||||
}
|
}
|
||||||
html("</span>");
|
html("</span>");
|
||||||
|
Loading…
Reference in New Issue
Block a user