|
diff --git a/ui-diff.c b/ui-diff.c index 1c182aa..7ab1e49 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -7,25 +7,24 @@ |
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 | |
12 | |
13 | unsigned char old_rev_sha1[20]; |
13 | unsigned char old_rev_sha1[20]; |
14 | unsigned char new_rev_sha1[20]; |
14 | unsigned char new_rev_sha1[20]; |
15 | |
15 | |
16 | static int files, slots; |
16 | static int files, slots; |
17 | static int total_adds, total_rems, max_changes; |
17 | static int total_adds, total_rems, max_changes; |
18 | static int lines_added, lines_removed; |
18 | static int lines_added, lines_removed; |
19 | static char *curr_rev; |
| |
20 | |
19 | |
21 | static struct fileinfo { |
20 | static struct fileinfo { |
22 | char status; |
21 | char status; |
23 | unsigned char old_sha1[20]; |
22 | unsigned char old_sha1[20]; |
24 | unsigned char new_sha1[20]; |
23 | unsigned char new_sha1[20]; |
25 | unsigned short old_mode; |
24 | unsigned short old_mode; |
26 | unsigned short new_mode; |
25 | unsigned short new_mode; |
27 | char *old_path; |
26 | char *old_path; |
28 | char *new_path; |
27 | char *new_path; |
29 | unsigned int added; |
28 | unsigned int added; |
30 | unsigned int removed; |
29 | unsigned int removed; |
31 | } *items; |
30 | } *items; |
@@ -71,26 +70,26 @@ static void print_fileinfo(struct fileinfo *info) |
71 | } else { |
70 | } else { |
72 | cgit_print_filemode(info->new_mode); |
71 | cgit_print_filemode(info->new_mode); |
73 | } |
72 | } |
74 | |
73 | |
75 | if (info->old_mode != info->new_mode && |
74 | if (info->old_mode != info->new_mode && |
76 | !is_null_sha1(info->old_sha1) && |
75 | !is_null_sha1(info->old_sha1) && |
77 | !is_null_sha1(info->new_sha1)) { |
76 | !is_null_sha1(info->new_sha1)) { |
78 | html("<span class='modechange'>["); |
77 | html("<span class='modechange'>["); |
79 | cgit_print_filemode(info->old_mode); |
78 | cgit_print_filemode(info->old_mode); |
80 | html("]</span>"); |
79 | html("]</span>"); |
81 | } |
80 | } |
82 | htmlf("</td><td class='%s'>", class); |
81 | htmlf("</td><td class='%s'>", class); |
83 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, curr_rev, |
82 | cgit_diff_link(info->new_path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
84 | NULL, info->new_path); |
83 | ctx.qry.sha2, info->new_path); |
85 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
84 | if (info->status == DIFF_STATUS_COPIED || info->status == DIFF_STATUS_RENAMED) |
86 | htmlf(" (%s from %s)", |
85 | htmlf(" (%s from %s)", |
87 | info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", |
86 | info->status == DIFF_STATUS_COPIED ? "copied" : "renamed", |
88 | info->old_path); |
87 | info->old_path); |
89 | html("</td><td class='right'>"); |
88 | html("</td><td class='right'>"); |
90 | htmlf("%d", info->added + info->removed); |
89 | htmlf("%d", info->added + info->removed); |
91 | html("</td><td class='graph'>"); |
90 | html("</td><td class='graph'>"); |
92 | htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); |
91 | htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes)); |
93 | htmlf("<td class='add' style='width: %.1f%%;'/>", |
92 | htmlf("<td class='add' style='width: %.1f%%;'/>", |
94 | info->added * 100.0 / max_changes); |
93 | info->added * 100.0 / max_changes); |
95 | htmlf("<td class='rem' style='width: %.1f%%;'/>", |
94 | htmlf("<td class='rem' style='width: %.1f%%;'/>", |
96 | info->removed * 100.0 / max_changes); |
95 | info->removed * 100.0 / max_changes); |
@@ -136,25 +135,24 @@ static void inspect_filepair(struct diff_filepair *pair) |
136 | total_adds += lines_added; |
135 | total_adds += lines_added; |
137 | total_rems += lines_removed; |
136 | total_rems += lines_removed; |
138 | } |
137 | } |
139 | |
138 | |
140 | void cgit_print_diffstat(const unsigned char *old_sha1, |
139 | void cgit_print_diffstat(const unsigned char *old_sha1, |
141 | const unsigned char *new_sha1) |
140 | const unsigned char *new_sha1) |
142 | { |
141 | { |
143 | int i; |
142 | int i; |
144 | |
143 | |
145 | html("<div class='diffstat-header'>Diffstat</div>"); |
144 | html("<div class='diffstat-header'>Diffstat</div>"); |
146 | html("<table summary='diffstat' class='diffstat'>"); |
145 | html("<table summary='diffstat' class='diffstat'>"); |
147 | max_changes = 0; |
146 | max_changes = 0; |
148 | curr_rev = xstrdup(sha1_to_hex(new_sha1)); |
| |
149 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL); |
147 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, NULL); |
150 | for(i = 0; i<files; i++) |
148 | for(i = 0; i<files; i++) |
151 | print_fileinfo(&items[i]); |
149 | print_fileinfo(&items[i]); |
152 | html("</table>"); |
150 | html("</table>"); |
153 | html("<div class='diffstat-summary'>"); |
151 | html("<div class='diffstat-summary'>"); |
154 | htmlf("%d files changed, %d insertions, %d deletions", |
152 | htmlf("%d files changed, %d insertions, %d deletions", |
155 | files, total_adds, total_rems); |
153 | files, total_adds, total_rems); |
156 | html("</div>"); |
154 | html("</div>"); |
157 | } |
155 | } |
158 | |
156 | |
159 | |
157 | |
160 | /* |
158 | /* |
|