X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/148fb9622c6a96021e572d1a372e38896506031f..820df9c66073b1345397642b46f1885b40b620e3:/ui-commit.c diff --git a/ui-commit.c b/ui-commit.c index 2d38f0b..a5a6ea8 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -1,69 +1,144 @@ +/* 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 "ui-commit.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, const char *prefix) { - struct commit *commit; - struct commitinfo *info; + struct commit *commit, *parent; + struct commitinfo *info, *parent_info; struct commit_list *p; - unsigned long size; - char type[20]; - char *buf; - + struct strbuf notes = STRBUF_INIT; unsigned char sha1[20]; + char *tmp, *tmp2; + int parents = 0; - if (get_sha1(hex, sha1)) { - cgit_print_error(fmt("Bad object id: %s", hex)); - return; - } + if (!hex) + hex = ctx.qry.head; - buf = read_sha1_file(sha1, type, &size); - if (!buf) { - cgit_print_error(fmt("Bad object reference: %s", hex)); + if (get_sha1(hex, sha1)) { + cgit_print_error("Bad object id: %s", hex); return; } - - commit = lookup_commit(sha1); + commit = lookup_commit_reference(sha1); if (!commit) { - cgit_print_error(fmt("Bad commit reference: %s", hex)); + cgit_print_error("Bad commit reference: %s", hex); return; } + info = cgit_parse_commit(commit); - commit->buffer = buf; - if (parse_commit_buffer(commit, buf, size)) { - cgit_print_error(fmt("Malformed commit buffer: %s", hex)); - return; - } + format_display_notes(sha1, ¬es, PAGE_ENCODING, 0); - info = cgit_parse_commit(commit); + load_ref_decorations(DECORATE_FULL_REFS); - html("
| author | ");
+ cgit_print_diff_ctrls();
+ html("
");
+ if (ctx.repo->commit_filter)
+ cgit_open_filter(ctx.repo->commit_filter);
html_txt(info->subject);
+ if (ctx.repo->commit_filter)
+ cgit_close_filter(ctx.repo->commit_filter);
+ show_commit_decorations(commit);
html(" ");
html("");
+ if (ctx.repo->commit_filter)
+ cgit_open_filter(ctx.repo->commit_filter);
html_txt(info->msg);
+ if (ctx.repo->commit_filter)
+ cgit_close_filter(ctx.repo->commit_filter);
html(" ");
- free(info->author);
- free(info->committer);
- free(info->subject);
- free(info);
+ if (notes.len != 0) {
+ html("Notes ");
+ html("");
+ if (ctx.repo->commit_filter)
+ cgit_open_filter(ctx.repo->commit_filter);
+ html_txt(notes.buf);
+ if (ctx.repo->commit_filter)
+ cgit_close_filter(ctx.repo->commit_filter);
+ html(" ");
+ html("");
+ }
+ if (parents < 3) {
+ if (parents)
+ tmp = sha1_to_hex(commit->parents->item->object.sha1);
+ else
+ tmp = NULL;
+ cgit_print_diff(ctx.qry.sha1, tmp, prefix, 0);
+ }
+ strbuf_release(¬es);
+ cgit_free_commitinfo(info);
}
| ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|