auth-filters: do not use HMAC-SHA1
[cgit.git] / ui-commit.c
blob995cb9345addb03fc4eef95c1004a671d4f00d09
1 /* ui-commit.c: generate commit view
3 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
9 #include "cgit.h"
10 #include "ui-commit.h"
11 #include "html.h"
12 #include "ui-shared.h"
13 #include "ui-diff.h"
14 #include "ui-log.h"
16 void cgit_print_commit(char *hex, const char *prefix)
18 struct commit *commit, *parent;
19 struct commitinfo *info, *parent_info;
20 struct commit_list *p;
21 struct strbuf notes = STRBUF_INIT;
22 struct object_id oid;
23 char *tmp, *tmp2;
24 int parents = 0;
26 if (!hex)
27 hex = ctx.qry.head;
29 if (get_oid(hex, &oid)) {
30 cgit_print_error_page(400, "Bad request",
31 "Bad object id: %s", hex);
32 return;
34 commit = lookup_commit_reference(&oid);
35 if (!commit) {
36 cgit_print_error_page(404, "Not found",
37 "Bad commit reference: %s", hex);
38 return;
40 info = cgit_parse_commit(commit);
42 format_display_notes(&oid, &notes, PAGE_ENCODING, 0);
44 load_ref_decorations(NULL, DECORATE_FULL_REFS);
46 cgit_print_layout_start();
47 cgit_print_diff_ctrls();
48 html("<table summary='commit info' class='commit-info'>\n");
49 html("<tr><th>author</th><td>");
50 cgit_open_filter(ctx.repo->email_filter, info->author_email, "commit");
51 html_txt(info->author);
52 if (!ctx.cfg.noplainemail) {
53 html(" ");
54 html_txt(info->author_email);
56 cgit_close_filter(ctx.repo->email_filter);
57 html("</td><td class='right'>");
58 html_txt(show_date(info->author_date, info->author_tz,
59 cgit_date_mode(DATE_ISO8601)));
60 html("</td></tr>\n");
61 html("<tr><th>committer</th><td>");
62 cgit_open_filter(ctx.repo->email_filter, info->committer_email, "commit");
63 html_txt(info->committer);
64 if (!ctx.cfg.noplainemail) {
65 html(" ");
66 html_txt(info->committer_email);
68 cgit_close_filter(ctx.repo->email_filter);
69 html("</td><td class='right'>");
70 html_txt(show_date(info->committer_date, info->committer_tz,
71 cgit_date_mode(DATE_ISO8601)));
72 html("</td></tr>\n");
73 html("<tr><th>commit</th><td colspan='2' class='sha1'>");
74 tmp = oid_to_hex(&commit->object.oid);
75 cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, prefix);
76 html(" (");
77 cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
78 html(")</td></tr>\n");
79 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
80 tmp = xstrdup(hex);
81 cgit_tree_link(oid_to_hex(&commit->maybe_tree->object.oid), NULL, NULL,
82 ctx.qry.head, tmp, NULL);
83 if (prefix) {
84 html(" /");
85 cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tmp, prefix);
87 free(tmp);
88 html("</td></tr>\n");
89 for (p = commit->parents; p; p = p->next) {
90 parent = lookup_commit_reference(&p->item->object.oid);
91 if (!parent) {
92 html("<tr><td colspan='3'>");
93 cgit_print_error("Error reading parent commit");
94 html("</td></tr>");
95 continue;
97 html("<tr><th>parent</th>"
98 "<td colspan='2' class='sha1'>");
99 tmp = tmp2 = oid_to_hex(&p->item->object.oid);
100 if (ctx.repo->enable_subject_links) {
101 parent_info = cgit_parse_commit(parent);
102 tmp2 = parent_info->subject;
104 cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, prefix);
105 html(" (");
106 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
107 oid_to_hex(&p->item->object.oid), prefix);
108 html(")</td></tr>");
109 parents++;
111 if (ctx.repo->snapshots) {
112 html("<tr><th>download</th><td colspan='2' class='sha1'>");
113 cgit_print_snapshot_links(ctx.repo, hex, "<br/>");
114 html("</td></tr>");
116 html("</table>\n");
117 html("<div class='commit-subject'>");
118 cgit_open_filter(ctx.repo->commit_filter);
119 html_txt(info->subject);
120 cgit_close_filter(ctx.repo->commit_filter);
121 show_commit_decorations(commit);
122 html("</div>");
123 html("<div class='commit-msg'>");
124 cgit_open_filter(ctx.repo->commit_filter);
125 html_txt(info->msg);
126 cgit_close_filter(ctx.repo->commit_filter);
127 html("</div>");
128 if (notes.len != 0) {
129 html("<div class='notes-header'>Notes</div>");
130 html("<div class='notes'>");
131 cgit_open_filter(ctx.repo->commit_filter);
132 html_txt(notes.buf);
133 cgit_close_filter(ctx.repo->commit_filter);
134 html("</div>");
135 html("<div class='notes-footer'></div>");
137 if (parents < 3) {
138 if (parents)
139 tmp = oid_to_hex(&commit->parents->item->object.oid);
140 else
141 tmp = NULL;
142 cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0, 0);
144 strbuf_release(&notes);
145 cgit_free_commitinfo(info);
146 cgit_print_layout_end();