X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/148fb9622c6a96021e572d1a372e38896506031f..b115955d71c50cd2d0065c45f3df6b02fa4730bd:/ui-commit.c diff --git a/ui-commit.c b/ui-commit.c index 2d38f0b..41ce70e 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -1,69 +1,106 @@ +/* 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" +#include "ui-log.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; + int parents = 0; + + 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 | ");
+ load_ref_decorations();
+
+ html("
");
html_txt(info->subject);
+ show_commit_decorations(commit);
html(" ");
html("");
html_txt(info->msg);
html(" ");
- free(info->author);
- free(info->committer);
- free(info->subject);
- free(info);
+ if (parents < 3) {
+ if (parents)
+ tmp = sha1_to_hex(commit->parents->item->object.sha1);
+ else
+ tmp = NULL;
+ cgit_print_diff(ctx.qry.sha1, tmp, NULL);
+ }
+ cgit_free_commitinfo(info);
}
| ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|