-rw-r--r-- | ui-commit.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ui-commit.c b/ui-commit.c index 8019e36..dd36cc0 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -1,43 +1,44 @@ /* ui-commit.c: generate commit view * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" #include "html.h" #include "ui-shared.h" +#include "ui-diff.h" static int files, slots; static int total_adds, total_rems, max_changes; static int lines_added, lines_removed; static char *curr_rev; static struct fileinfo { char status; unsigned char old_sha1[20]; unsigned char new_sha1[20]; unsigned short old_mode; unsigned short new_mode; char *old_path; char *new_path; unsigned int added; unsigned int removed; } *items; void print_fileinfo(struct fileinfo *info) { char *class; switch (info->status) { case DIFF_STATUS_ADDED: class = "add"; break; case DIFF_STATUS_COPIED: class = "cpy"; break; case DIFF_STATUS_DELETED: class = "del"; @@ -145,84 +146,91 @@ void cgit_print_commit(char *hex) int i; if (!hex) hex = ctx.qry.head; curr_rev = hex; if (get_sha1(hex, sha1)) { cgit_print_error(fmt("Bad object id: %s", hex)); return; } commit = lookup_commit_reference(sha1); if (!commit) { cgit_print_error(fmt("Bad commit reference: %s", hex)); return; } info = cgit_parse_commit(commit); html("<table summary='commit info' class='commit-info'>\n"); html("<tr><th>author</th><td>"); html_txt(info->author); html(" "); html_txt(info->author_email); html("</td><td class='right'>"); cgit_print_date(info->author_date, FMT_LONGDATE); html("</td></tr>\n"); html("<tr><th>committer</th><td>"); html_txt(info->committer); html(" "); html_txt(info->committer_email); html("</td><td class='right'>"); cgit_print_date(info->committer_date, FMT_LONGDATE); html("</td></tr>\n"); + html("<tr><th>commit</th><td colspan='2' class='sha1'>"); + tmp = sha1_to_hex(commit->object.sha1); + cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp); + html(" ("); + cgit_patch_link("patch", NULL, NULL, NULL, tmp); + html(")</td></tr>\n"); html("<tr><th>tree</th><td colspan='2' class='sha1'>"); tmp = xstrdup(hex); cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, ctx.qry.head, tmp, NULL); html("</td></tr>\n"); for (p = commit->parents; p ; p = p->next) { parent = lookup_commit_reference(p->item->object.sha1); if (!parent) { html("<tr><td colspan='3'>"); cgit_print_error("Error reading parent commit"); html("</td></tr>"); continue; } html("<tr><th>parent</th>" "<td colspan='2' class='sha1'>"); cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, ctx.qry.head, sha1_to_hex(p->item->object.sha1)); html(" ("); cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, sha1_to_hex(p->item->object.sha1), NULL); html(")</td></tr>"); } if (ctx.repo->snapshots) { html("<tr><th>download</th><td colspan='2' class='sha1'>"); cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, hex, ctx.repo->snapshots); html("</td></tr>"); } html("</table>\n"); html("<div class='commit-subject'>"); html_txt(info->subject); html("</div>"); html("<div class='commit-msg'>"); html_txt(info->msg); html("</div>"); if (!(commit->parents && commit->parents->next && commit->parents->next->next)) { html("<div class='diffstat-header'>Diffstat</div>"); html("<table summary='diffstat' class='diffstat'>"); max_changes = 0; cgit_diff_commit(commit, inspect_filepair); for(i = 0; i<files; i++) print_fileinfo(&items[i]); html("</table>"); html("<div class='diffstat-summary'>"); - htmlf("%d files changed, %d insertions, %d deletions (", + htmlf("%d files changed, %d insertions, %d deletions", files, total_adds, total_rems); - cgit_diff_link("show diff", NULL, NULL, ctx.qry.head, hex, - NULL, NULL); + cgit_print_diff(ctx.qry.sha1, + sha1_to_hex(commit->parents->item->object.sha1), + NULL); html(")</div>"); } cgit_free_commitinfo(info); } |