3 void cgit_print_date(unsigned long secs)
9 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
14 void cgit_print_commit(const char *hex)
16 struct commit *commit;
17 struct commitinfo *info;
18 struct commit_list *p;
23 unsigned char sha1[20];
25 if (get_sha1(hex, sha1)) {
26 cgit_print_error(fmt("Bad object id: %s", hex));
30 buf = read_sha1_file(sha1, type, &size);
32 cgit_print_error(fmt("Bad object reference: %s", hex));
36 commit = lookup_commit(sha1);
38 cgit_print_error(fmt("Bad commit reference: %s", hex));
43 if (parse_commit_buffer(commit, buf, size)) {
44 cgit_print_error(fmt("Malformed commit buffer: %s", hex));
48 info = cgit_parse_commit(commit);
50 html("<table class='commit-info'>\n");
51 html("<tr><th>author</th><td colspan='2'>");
52 html_txt(info->author);
54 html("<tr><th>committer</th><td>");
55 html_txt(info->committer);
56 html("</td><td class='right'>");
57 cgit_print_date(commit->date);
59 html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='");
60 html_attr(cgit_pageurl(cgit_query_repo, "tree", fmt("id=%s", sha1_to_hex(commit->tree->object.sha1))));
61 htmlf("'>%s</a></td></tr>\n", sha1_to_hex(commit->tree->object.sha1));
63 for (p = commit->parents; p ; p = p->next) {
64 html("<tr><th>parent</th><td colspan='2' class='sha1'><a href='");
65 html_attr(cgit_pageurl(cgit_query_repo, "commit", fmt("id=%s", sha1_to_hex(p->item->object.sha1))));
66 htmlf("'>%s</a></td></tr>\n",
67 sha1_to_hex(p->item->object.sha1));
70 html("<div class='commit-subject'>");
71 html_txt(info->subject);
73 html("<div class='commit-msg'>");
77 free(info->committer);