-rw-r--r-- | ui-commit.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ui-commit.c b/ui-commit.c index 2d38f0b..2d36015 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -1,48 +1,56 @@ | |||
1 | /* ui-commit.c: generate commit view | ||
2 | * | ||
3 | * Copyright (C) 2006 Lars Hjemli | ||
4 | * | ||
5 | * Licensed under GNU General Public License v2 | ||
6 | * (see COPYING for full license text) | ||
7 | */ | ||
8 | |||
1 | #include "cgit.h" | 9 | #include "cgit.h" |
2 | 10 | ||
3 | void cgit_print_commit(const char *hex) | 11 | void cgit_print_commit(const char *hex) |
4 | { | 12 | { |
5 | struct commit *commit; | 13 | struct commit *commit; |
6 | struct commitinfo *info; | 14 | struct commitinfo *info; |
7 | struct commit_list *p; | 15 | struct commit_list *p; |
8 | unsigned long size; | 16 | unsigned long size; |
9 | char type[20]; | 17 | char type[20]; |
10 | char *buf; | 18 | char *buf; |
11 | 19 | ||
12 | unsigned char sha1[20]; | 20 | unsigned char sha1[20]; |
13 | 21 | ||
14 | if (get_sha1(hex, sha1)) { | 22 | if (get_sha1(hex, sha1)) { |
15 | cgit_print_error(fmt("Bad object id: %s", hex)); | 23 | cgit_print_error(fmt("Bad object id: %s", hex)); |
16 | return; | 24 | return; |
17 | } | 25 | } |
18 | 26 | ||
19 | buf = read_sha1_file(sha1, type, &size); | 27 | buf = read_sha1_file(sha1, type, &size); |
20 | if (!buf) { | 28 | if (!buf) { |
21 | cgit_print_error(fmt("Bad object reference: %s", hex)); | 29 | cgit_print_error(fmt("Bad object reference: %s", hex)); |
22 | return; | 30 | return; |
23 | } | 31 | } |
24 | 32 | ||
25 | commit = lookup_commit(sha1); | 33 | commit = lookup_commit(sha1); |
26 | if (!commit) { | 34 | if (!commit) { |
27 | cgit_print_error(fmt("Bad commit reference: %s", hex)); | 35 | cgit_print_error(fmt("Bad commit reference: %s", hex)); |
28 | return; | 36 | return; |
29 | } | 37 | } |
30 | 38 | ||
31 | commit->buffer = buf; | 39 | commit->buffer = buf; |
32 | if (parse_commit_buffer(commit, buf, size)) { | 40 | if (parse_commit_buffer(commit, buf, size)) { |
33 | cgit_print_error(fmt("Malformed commit buffer: %s", hex)); | 41 | cgit_print_error(fmt("Malformed commit buffer: %s", hex)); |
34 | return; | 42 | return; |
35 | } | 43 | } |
36 | 44 | ||
37 | info = cgit_parse_commit(commit); | 45 | info = cgit_parse_commit(commit); |
38 | 46 | ||
39 | html("<table class='commit-info'>\n"); | 47 | html("<table class='commit-info'>\n"); |
40 | html("<tr><th>author</th><td colspan='2'>"); | 48 | html("<tr><th>author</th><td colspan='2'>"); |
41 | html_txt(info->author); | 49 | html_txt(info->author); |
42 | html("</td></tr>\n"); | 50 | html("</td></tr>\n"); |
43 | html("<tr><th>committer</th><td>"); | 51 | html("<tr><th>committer</th><td>"); |
44 | html_txt(info->committer); | 52 | html_txt(info->committer); |
45 | html("</td><td class='right'>"); | 53 | html("</td><td class='right'>"); |
46 | cgit_print_date(commit->date); | 54 | cgit_print_date(commit->date); |
47 | html("</td></tr>\n"); | 55 | html("</td></tr>\n"); |
48 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); | 56 | html("<tr><th>tree</th><td colspan='2' class='sha1'><a href='"); |