Diff options
Diffstat (limited to '')
| -rw-r--r-- | source/ui-commit.c | 58 |
1 file changed, 18 insertions, 40 deletions
diff --git a/source/ui-commit.c b/source/ui-commit.c index 63f2b7e..0916c33 100644 --- a/source/ui-commit.c +++ b/source/ui-commit.c @@ -1,10 +1,9 @@ /* - * The commit page, which shows one commit on its own and is where the log and - * the ref listings link. It renders the idents, the object ids, the message, - * the trailer table when the repository asks for one and any note, then hands - * off to ui-diff.c for the diff against the first parent. Free text and - * addresses are written through the repository's commit, trailer and email - * filters, so a site can rewrite any of them on the way out. + * The commit page renders the idents, the object ids, the message, the trailer + * table when the repository asks for one and any note, then hands off to + * ui-diff.c for the diff against the first parent. Free text and addresses are + * written through the repository's commit, trailer and email filters, so a + * site can rewrite any of them on the way out. */ #define USE_THE_REPOSITORY_VARIABLE @@ -13,7 +12,6 @@ #include "filter.h" #include "html.h" #include "parsing.h" -#include "shared.h" #include "ui-commit.h" #include "ui-diff.h" #include "ui-log.h" @@ -32,18 +30,10 @@ static void print_ident_row(const char *role, const char *name, const char *emai timestamp_t date, int tz) { htmlf("<tr><th scope='row'>%s</th><td>", role); - cgit_open_filter(ctx.repo->email_filter, email ? email : "", "commit"); - html_txt(name); - if (ctx.cfg.enable_plain_email) { - html(" "); - html_txt(email); - } - cgit_close_filter(ctx.repo->email_filter); - html("</td><td class='right'><time datetime='"); - html_attr(show_date(date, tz, cgit_date_mode(DATE_ISO8601_STRICT))); - html("'>"); - html_txt(show_date(date, tz, cgit_date_mode(DATE_ISO8601))); - html("</time></td></tr>\n"); + cgit_print_person(name, email, "commit", 1); + html("</td><td class='right'>"); + cgit_print_date(date, tz); + html("</td></tr>\n"); } /* @@ -106,6 +96,7 @@ static void print_trailer_value(const char *key, const char *value) struct string_list *map; struct strbuf email = STRBUF_INIT; const char *name, *mail, *rest; + char *who; size_t name_len, mail_len; if (!split_ident_line(&ident, value, strlen(value)) && @@ -120,13 +111,9 @@ static void print_trailer_value(const char *key, const char *value) strbuf_addch(&email, '<'); strbuf_add(&email, mail, mail_len); strbuf_addch(&email, '>'); - cgit_open_filter(ctx.repo->email_filter, email.buf, "commit"); - html_ntxt(name, name_len); - if (ctx.cfg.enable_plain_email) { - html(" "); - html_txt(email.buf); - } - cgit_close_filter(ctx.repo->email_filter); + who = xmemdupz(name, name_len); + cgit_print_person(who, email.buf, "commit", 1); + free(who); strbuf_release(&email); rest = ident.mail_end + 1; while (isspace((unsigned char)*rest)) @@ -247,28 +234,21 @@ void cgit_print_commit(char *hex, const char *prefix) struct object_id oid, first_oid; const char *commit_hex; char *first_parent; - char *tree_rev; int parents; if (!hex) hex = ctx.qry.head; - if (repo_get_oid(the_repository, hex, &oid)) { - cgit_print_error_page(404, "Not Found", "Bad object id: %s", hex); + commit = cgit_get_commit(hex, &oid); + if (!commit) return; - } - commit = lookup_commit_reference(the_repository, &oid); - if (!commit) { - cgit_print_error_page(404, "Not Found", "Not a commit: %s", hex); - return; - } info = cgit_parse_commit(commit); format_display_notes(&commit->object.oid, ¬es, PAGE_ENCODING, 1); load_ref_decorations(NULL, DECORATE_FULL_REFS); - ctx.page.title = cgit_fmtalloc("%s - %s", info->subject, ctx.page.title); + ctx.page.title = xstrfmt("%s - %s", info->subject, ctx.page.title); cgit_print_layout_start(); // An octopus merge draws no diff, so it has no options to offer. if (commit_list_count(commit->parents) < OCTOPUS_PARENTS) @@ -293,13 +273,11 @@ void cgit_print_commit(char *hex, const char *prefix) parents = print_parent_rows(commit, hex, prefix, &first_oid); html("<tr><th scope='row'>tree</th><td colspan='2' class='oid'><div class='spanning'>"); - tree_rev = xstrdup(hex); - cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL, ctx.qry.head, tree_rev, NULL); + cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL, ctx.qry.head, hex, NULL); if (prefix) { html(" /"); - cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tree_rev, prefix); + cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, hex, prefix); } - free(tree_rev); html("</div></td></tr>\n"); if (ctx.repo->snapshots) { |
