summaryrefslogtreecommitdiffabout
path: root/ui-commit.c
authorLars Hjemli <hjemli@gmail.com>2008-04-12 13:53:53 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-04-12 18:00:40 (UTC)
commit89aa3c0d0a4c6d9885272602005975b763ea1604 (patch) (unidiff)
tree4527f91c87d65426e5cd72b1d3e9da2d37ceb6d3 /ui-commit.c
parentf135569b2be3fb1816f802f9a162b3743b735d1c (diff)
downloadcgit-89aa3c0d0a4c6d9885272602005975b763ea1604.zip
cgit-89aa3c0d0a4c6d9885272602005975b763ea1604.tar.gz
cgit-89aa3c0d0a4c6d9885272602005975b763ea1604.tar.bz2
Include diff in commit view
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-commit.c') (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,23 +1,24 @@
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;
@@ -209,20 +210,21 @@ void cgit_print_commit(char *hex)
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}