author | Jeff Smith <whydoubt@yahoo.com> | 2010-07-29 14:32:30 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-08-04 01:10:07 (UTC) |
commit | 059b39344fdcde324dff1099fc4b70c7aab12a96 (patch) (unidiff) | |
tree | 4a12cf7645b89c06684e09a1e5dded9a5ddeae38 /ui-commit.c | |
parent | f9143171267e39f66a02ad2ecb0da2e8cc7f4142 (diff) | |
download | cgit-059b39344fdcde324dff1099fc4b70c7aab12a96.zip cgit-059b39344fdcde324dff1099fc4b70c7aab12a96.tar.gz cgit-059b39344fdcde324dff1099fc4b70c7aab12a96.tar.bz2 |
ui-commit: Display git notes when present
Signed-off-by: Jeff Smith <whydoubt@yahoo.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-commit.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ui-commit.c b/ui-commit.c index a11bc5f..45af450 100644 --- a/ui-commit.c +++ b/ui-commit.c | |||
@@ -4,50 +4,53 @@ | |||
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | #include "ui-diff.h" | 12 | #include "ui-diff.h" |
13 | #include "ui-log.h" | 13 | #include "ui-log.h" |
14 | 14 | ||
15 | void cgit_print_commit(char *hex, const char *prefix) | 15 | void cgit_print_commit(char *hex, const char *prefix) |
16 | { | 16 | { |
17 | struct commit *commit, *parent; | 17 | struct commit *commit, *parent; |
18 | struct commitinfo *info, *parent_info; | 18 | struct commitinfo *info, *parent_info; |
19 | struct commit_list *p; | 19 | struct commit_list *p; |
20 | struct strbuf notes = STRBUF_INIT; | ||
20 | unsigned char sha1[20]; | 21 | unsigned char sha1[20]; |
21 | char *tmp, *tmp2; | 22 | char *tmp, *tmp2; |
22 | int parents = 0; | 23 | int parents = 0; |
23 | 24 | ||
24 | if (!hex) | 25 | if (!hex) |
25 | hex = ctx.qry.head; | 26 | hex = ctx.qry.head; |
26 | 27 | ||
27 | if (get_sha1(hex, sha1)) { | 28 | if (get_sha1(hex, sha1)) { |
28 | cgit_print_error(fmt("Bad object id: %s", hex)); | 29 | cgit_print_error(fmt("Bad object id: %s", hex)); |
29 | return; | 30 | return; |
30 | } | 31 | } |
31 | commit = lookup_commit_reference(sha1); | 32 | commit = lookup_commit_reference(sha1); |
32 | if (!commit) { | 33 | if (!commit) { |
33 | cgit_print_error(fmt("Bad commit reference: %s", hex)); | 34 | cgit_print_error(fmt("Bad commit reference: %s", hex)); |
34 | return; | 35 | return; |
35 | } | 36 | } |
36 | info = cgit_parse_commit(commit); | 37 | info = cgit_parse_commit(commit); |
37 | 38 | ||
39 | get_commit_notes(commit, ¬es, PAGE_ENCODING, 0); | ||
40 | |||
38 | load_ref_decorations(DECORATE_FULL_REFS); | 41 | load_ref_decorations(DECORATE_FULL_REFS); |
39 | 42 | ||
40 | html("<table summary='commit info' class='commit-info'>\n"); | 43 | html("<table summary='commit info' class='commit-info'>\n"); |
41 | html("<tr><th>author</th><td>"); | 44 | html("<tr><th>author</th><td>"); |
42 | html_txt(info->author); | 45 | html_txt(info->author); |
43 | if (!ctx.cfg.noplainemail) { | 46 | if (!ctx.cfg.noplainemail) { |
44 | html(" "); | 47 | html(" "); |
45 | html_txt(info->author_email); | 48 | html_txt(info->author_email); |
46 | } | 49 | } |
47 | html("</td><td class='right'>"); | 50 | html("</td><td class='right'>"); |
48 | cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); | 51 | cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); |
49 | html("</td></tr>\n"); | 52 | html("</td></tr>\n"); |
50 | html("<tr><th>committer</th><td>"); | 53 | html("<tr><th>committer</th><td>"); |
51 | html_txt(info->committer); | 54 | html_txt(info->committer); |
52 | if (!ctx.cfg.noplainemail) { | 55 | if (!ctx.cfg.noplainemail) { |
53 | html(" "); | 56 | html(" "); |
@@ -107,25 +110,37 @@ void cgit_print_commit(char *hex, const char *prefix) | |||
107 | html("</table>\n"); | 110 | html("</table>\n"); |
108 | html("<div class='commit-subject'>"); | 111 | html("<div class='commit-subject'>"); |
109 | if (ctx.repo->commit_filter) | 112 | if (ctx.repo->commit_filter) |
110 | cgit_open_filter(ctx.repo->commit_filter); | 113 | cgit_open_filter(ctx.repo->commit_filter); |
111 | html_txt(info->subject); | 114 | html_txt(info->subject); |
112 | if (ctx.repo->commit_filter) | 115 | if (ctx.repo->commit_filter) |
113 | cgit_close_filter(ctx.repo->commit_filter); | 116 | cgit_close_filter(ctx.repo->commit_filter); |
114 | show_commit_decorations(commit); | 117 | show_commit_decorations(commit); |
115 | html("</div>"); | 118 | html("</div>"); |
116 | html("<div class='commit-msg'>"); | 119 | html("<div class='commit-msg'>"); |
117 | if (ctx.repo->commit_filter) | 120 | if (ctx.repo->commit_filter) |
118 | cgit_open_filter(ctx.repo->commit_filter); | 121 | cgit_open_filter(ctx.repo->commit_filter); |
119 | html_txt(info->msg); | 122 | html_txt(info->msg); |
120 | if (ctx.repo->commit_filter) | 123 | if (ctx.repo->commit_filter) |
121 | cgit_close_filter(ctx.repo->commit_filter); | 124 | cgit_close_filter(ctx.repo->commit_filter); |
122 | html("</div>"); | 125 | html("</div>"); |
126 | if (notes.len != 0) { | ||
127 | html("<div class='notes-header'>Notes</div>"); | ||
128 | html("<div class='notes'>"); | ||
129 | if (ctx.repo->commit_filter) | ||
130 | cgit_open_filter(ctx.repo->commit_filter); | ||
131 | html_txt(notes.buf); | ||
132 | if (ctx.repo->commit_filter) | ||
133 | cgit_close_filter(ctx.repo->commit_filter); | ||
134 | html("</div>"); | ||
135 | html("<div class='notes-footer'></div>"); | ||
136 | } | ||
123 | if (parents < 3) { | 137 | if (parents < 3) { |
124 | if (parents) | 138 | if (parents) |
125 | tmp = sha1_to_hex(commit->parents->item->object.sha1); | 139 | tmp = sha1_to_hex(commit->parents->item->object.sha1); |
126 | else | 140 | else |
127 | tmp = NULL; | 141 | tmp = NULL; |
128 | cgit_print_diff(ctx.qry.sha1, tmp, prefix); | 142 | cgit_print_diff(ctx.qry.sha1, tmp, prefix); |
129 | } | 143 | } |
144 | strbuf_release(¬es); | ||
130 | cgit_free_commitinfo(info); | 145 | cgit_free_commitinfo(info); |
131 | } | 146 | } |