summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-commit.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ui-commit.c b/ui-commit.c
index 8019e36..c2fafd7 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -1,59 +1,60 @@
1/* ui-commit.c: generate commit view 1/* ui-commit.c: generate commit view
2 * 2 *
3 * Copyright (C) 2006 Lars Hjemli 3 * Copyright (C) 2006 Lars Hjemli
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 13
13static int files, slots; 14static int files, slots;
14static int total_adds, total_rems, max_changes; 15static int total_adds, total_rems, max_changes;
15static int lines_added, lines_removed; 16static int lines_added, lines_removed;
16static char *curr_rev; 17static char *curr_rev;
17 18
18static struct fileinfo { 19static struct fileinfo {
19 char status; 20 char status;
20 unsigned char old_sha1[20]; 21 unsigned char old_sha1[20];
21 unsigned char new_sha1[20]; 22 unsigned char new_sha1[20];
22 unsigned short old_mode; 23 unsigned short old_mode;
23 unsigned short new_mode; 24 unsigned short new_mode;
24 char *old_path; 25 char *old_path;
25 char *new_path; 26 char *new_path;
26 unsigned int added; 27 unsigned int added;
27 unsigned int removed; 28 unsigned int removed;
28} *items; 29} *items;
29 30
30 31
31void print_fileinfo(struct fileinfo *info) 32void print_fileinfo(struct fileinfo *info)
32{ 33{
33 char *class; 34 char *class;
34 35
35 switch (info->status) { 36 switch (info->status) {
36 case DIFF_STATUS_ADDED: 37 case DIFF_STATUS_ADDED:
37 class = "add"; 38 class = "add";
38 break; 39 break;
39 case DIFF_STATUS_COPIED: 40 case DIFF_STATUS_COPIED:
40 class = "cpy"; 41 class = "cpy";
41 break; 42 break;
42 case DIFF_STATUS_DELETED: 43 case DIFF_STATUS_DELETED:
43 class = "del"; 44 class = "del";
44 break; 45 break;
45 case DIFF_STATUS_MODIFIED: 46 case DIFF_STATUS_MODIFIED:
46 class = "upd"; 47 class = "upd";
47 break; 48 break;
48 case DIFF_STATUS_RENAMED: 49 case DIFF_STATUS_RENAMED:
49 class = "mov"; 50 class = "mov";
50 break; 51 break;
51 case DIFF_STATUS_TYPE_CHANGED: 52 case DIFF_STATUS_TYPE_CHANGED:
52 class = "typ"; 53 class = "typ";
53 break; 54 break;
54 case DIFF_STATUS_UNKNOWN: 55 case DIFF_STATUS_UNKNOWN:
55 class = "unk"; 56 class = "unk";
56 break; 57 break;
57 case DIFF_STATUS_UNMERGED: 58 case DIFF_STATUS_UNMERGED:
58 class = "stg"; 59 class = "stg";
59 break; 60 break;
@@ -173,56 +174,57 @@ void cgit_print_commit(char *hex)
173 html_txt(info->committer_email); 174 html_txt(info->committer_email);
174 html("</td><td class='right'>"); 175 html("</td><td class='right'>");
175 cgit_print_date(info->committer_date, FMT_LONGDATE); 176 cgit_print_date(info->committer_date, FMT_LONGDATE);
176 html("</td></tr>\n"); 177 html("</td></tr>\n");
177 html("<tr><th>tree</th><td colspan='2' class='sha1'>"); 178 html("<tr><th>tree</th><td colspan='2' class='sha1'>");
178 tmp = xstrdup(hex); 179 tmp = xstrdup(hex);
179 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL, 180 cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
180 ctx.qry.head, tmp, NULL); 181 ctx.qry.head, tmp, NULL);
181 html("</td></tr>\n"); 182 html("</td></tr>\n");
182 for (p = commit->parents; p ; p = p->next) { 183 for (p = commit->parents; p ; p = p->next) {
183 parent = lookup_commit_reference(p->item->object.sha1); 184 parent = lookup_commit_reference(p->item->object.sha1);
184 if (!parent) { 185 if (!parent) {
185 html("<tr><td colspan='3'>"); 186 html("<tr><td colspan='3'>");
186 cgit_print_error("Error reading parent commit"); 187 cgit_print_error("Error reading parent commit");
187 html("</td></tr>"); 188 html("</td></tr>");
188 continue; 189 continue;
189 } 190 }
190 html("<tr><th>parent</th>" 191 html("<tr><th>parent</th>"
191 "<td colspan='2' class='sha1'>"); 192 "<td colspan='2' class='sha1'>");
192 cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, 193 cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL,
193 ctx.qry.head, sha1_to_hex(p->item->object.sha1)); 194 ctx.qry.head, sha1_to_hex(p->item->object.sha1));
194 html(" ("); 195 html(" (");
195 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, 196 cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex,
196 sha1_to_hex(p->item->object.sha1), NULL); 197 sha1_to_hex(p->item->object.sha1), NULL);
197 html(")</td></tr>"); 198 html(")</td></tr>");
198 } 199 }
199 if (ctx.repo->snapshots) { 200 if (ctx.repo->snapshots) {
200 html("<tr><th>download</th><td colspan='2' class='sha1'>"); 201 html("<tr><th>download</th><td colspan='2' class='sha1'>");
201 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, 202 cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head,
202 hex, ctx.repo->snapshots); 203 hex, ctx.repo->snapshots);
203 html("</td></tr>"); 204 html("</td></tr>");
204 } 205 }
205 html("</table>\n"); 206 html("</table>\n");
206 html("<div class='commit-subject'>"); 207 html("<div class='commit-subject'>");
207 html_txt(info->subject); 208 html_txt(info->subject);
208 html("</div>"); 209 html("</div>");
209 html("<div class='commit-msg'>"); 210 html("<div class='commit-msg'>");
210 html_txt(info->msg); 211 html_txt(info->msg);
211 html("</div>"); 212 html("</div>");
212 if (!(commit->parents && commit->parents->next && commit->parents->next->next)) { 213 if (!(commit->parents && commit->parents->next && commit->parents->next->next)) {
213 html("<div class='diffstat-header'>Diffstat</div>"); 214 html("<div class='diffstat-header'>Diffstat</div>");
214 html("<table summary='diffstat' class='diffstat'>"); 215 html("<table summary='diffstat' class='diffstat'>");
215 max_changes = 0; 216 max_changes = 0;
216 cgit_diff_commit(commit, inspect_filepair); 217 cgit_diff_commit(commit, inspect_filepair);
217 for(i = 0; i<files; i++) 218 for(i = 0; i<files; i++)
218 print_fileinfo(&items[i]); 219 print_fileinfo(&items[i]);
219 html("</table>"); 220 html("</table>");
220 html("<div class='diffstat-summary'>"); 221 html("<div class='diffstat-summary'>");
221 htmlf("%d files changed, %d insertions, %d deletions (", 222 htmlf("%d files changed, %d insertions, %d deletions",
222 files, total_adds, total_rems); 223 files, total_adds, total_rems);
223 cgit_diff_link("show diff", NULL, NULL, ctx.qry.head, hex, 224 cgit_print_diff(ctx.qry.sha1,
224 NULL, NULL); 225 sha1_to_hex(commit->parents->item->object.sha1),
226 NULL);
225 html(")</div>"); 227 html(")</div>");
226 } 228 }
227 cgit_free_commitinfo(info); 229 cgit_free_commitinfo(info);
228} 230}