X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/6c14f5e457e17da9205588c273d7cb9f92a23b9f..71adba1f1678914063fc109cf3805afde2c68f75:/ui-commit.c diff --git a/ui-commit.c b/ui-commit.c index 2d36015..1aa5d34 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -7,61 +7,80 @@ */ #include "cgit.h" +#include "html.h" +#include "ui-shared.h" +#include "ui-diff.h" -void cgit_print_commit(const char *hex) +void cgit_print_commit(char *hex) { - struct commit *commit; + struct commit *commit, *parent; struct commitinfo *info; struct commit_list *p; - unsigned long size; - char type[20]; - char *buf; - unsigned char sha1[20]; + char *tmp; + + if (!hex) + hex = ctx.qry.head; if (get_sha1(hex, sha1)) { cgit_print_error(fmt("Bad object id: %s", hex)); return; } - - buf = read_sha1_file(sha1, type, &size); - if (!buf) { - cgit_print_error(fmt("Bad object reference: %s", hex)); - return; - } - - commit = lookup_commit(sha1); + commit = lookup_commit_reference(sha1); if (!commit) { cgit_print_error(fmt("Bad commit reference: %s", hex)); return; } - - commit->buffer = buf; - if (parse_commit_buffer(commit, buf, size)) { - cgit_print_error(fmt("Malformed commit buffer: %s", hex)); - return; - } - info = cgit_parse_commit(commit); - html("
| author | ");
+ html("
");
@@ -70,8 +89,10 @@ void cgit_print_commit(const char *hex)
html(" ");
html_txt(info->msg);
html(" ");
- free(info->author);
- free(info->committer);
- free(info->subject);
- free(info);
+ if (!(commit->parents && commit->parents->next &&
+ commit->parents->next->next)) {
+ tmp = sha1_to_hex(commit->parents->item->object.sha1);
+ cgit_print_diff(ctx.qry.sha1, tmp, NULL);
+ }
+ cgit_free_commitinfo(info);
}
| ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|