|
diff --git a/ui-diff.c b/ui-diff.c index 1656b77..0dcabe9 100644 --- a/ ui-diff.c+++ b/ ui-diff.c |
|
@@ -142,64 +142,69 @@ static void inspect_filepair(struct diff_filepair *pair) |
142 | items[files-1].new_mode = pair->two->mode; |
142 | items[files-1].new_mode = pair->two->mode; |
143 | items[files-1].old_path = xstrdup(pair->one->path); |
143 | items[files-1].old_path = xstrdup(pair->one->path); |
144 | items[files-1].new_path = xstrdup(pair->two->path); |
144 | items[files-1].new_path = xstrdup(pair->two->path); |
145 | items[files-1].added = lines_added; |
145 | items[files-1].added = lines_added; |
146 | items[files-1].removed = lines_removed; |
146 | items[files-1].removed = lines_removed; |
147 | items[files-1].old_size = old_size; |
147 | items[files-1].old_size = old_size; |
148 | items[files-1].new_size = new_size; |
148 | items[files-1].new_size = new_size; |
149 | items[files-1].binary = binary; |
149 | items[files-1].binary = binary; |
150 | if (lines_added + lines_removed > max_changes) |
150 | if (lines_added + lines_removed > max_changes) |
151 | max_changes = lines_added + lines_removed; |
151 | max_changes = lines_added + lines_removed; |
152 | total_adds += lines_added; |
152 | total_adds += lines_added; |
153 | total_rems += lines_removed; |
153 | total_rems += lines_removed; |
154 | } |
154 | } |
155 | |
155 | |
156 | void cgit_print_diffstat(const unsigned char *old_sha1, |
156 | void cgit_print_diffstat(const unsigned char *old_sha1, |
157 | const unsigned char *new_sha1, const char *prefix) |
157 | const unsigned char *new_sha1, const char *prefix) |
158 | { |
158 | { |
159 | int i, save_context = ctx.qry.context; |
159 | int i, save_context = ctx.qry.context; |
160 | |
160 | |
161 | html("<div class='diffstat-header'>"); |
161 | html("<div class='diffstat-header'>"); |
162 | cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
162 | cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
163 | ctx.qry.sha2, NULL, 0); |
163 | ctx.qry.sha2, NULL, 0); |
164 | if (prefix) |
164 | if (prefix) |
165 | htmlf(" (limited to '%s')", prefix); |
165 | htmlf(" (limited to '%s')", prefix); |
166 | html(" ("); |
166 | html(" ("); |
167 | ctx.qry.context = (save_context > 0 ? save_context : 3) << 1; |
167 | ctx.qry.context = (save_context > 0 ? save_context : 3) << 1; |
168 | cgit_self_link("more", NULL, NULL, &ctx); |
168 | cgit_self_link("more", NULL, NULL, &ctx); |
169 | html("/"); |
169 | html("/"); |
170 | ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1; |
170 | ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1; |
171 | cgit_self_link("less", NULL, NULL, &ctx); |
171 | cgit_self_link("less", NULL, NULL, &ctx); |
172 | ctx.qry.context = save_context; |
172 | ctx.qry.context = save_context; |
173 | html(" context)"); |
173 | html(" context)"); |
| |
174 | html(" ("); |
| |
175 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; |
| |
176 | cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx); |
| |
177 | ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2; |
| |
178 | html(" whitespace changes)"); |
174 | html("</div>"); |
179 | html("</div>"); |
175 | html("<table summary='diffstat' class='diffstat'>"); |
180 | html("<table summary='diffstat' class='diffstat'>"); |
176 | max_changes = 0; |
181 | max_changes = 0; |
177 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, |
182 | cgit_diff_tree(old_sha1, new_sha1, inspect_filepair, prefix, |
178 | ctx.qry.ignorews); |
183 | ctx.qry.ignorews); |
179 | for(i = 0; i<files; i++) |
184 | for(i = 0; i<files; i++) |
180 | print_fileinfo(&items[i]); |
185 | print_fileinfo(&items[i]); |
181 | html("</table>"); |
186 | html("</table>"); |
182 | html("<div class='diffstat-summary'>"); |
187 | html("<div class='diffstat-summary'>"); |
183 | htmlf("%d files changed, %d insertions, %d deletions", |
188 | htmlf("%d files changed, %d insertions, %d deletions", |
184 | files, total_adds, total_rems); |
189 | files, total_adds, total_rems); |
185 | html("</div>"); |
190 | html("</div>"); |
186 | } |
191 | } |
187 | |
192 | |
188 | |
193 | |
189 | /* |
194 | /* |
190 | * print a single line returned from xdiff |
195 | * print a single line returned from xdiff |
191 | */ |
196 | */ |
192 | static void print_line(char *line, int len) |
197 | static void print_line(char *line, int len) |
193 | { |
198 | { |
194 | char *class = "ctx"; |
199 | char *class = "ctx"; |
195 | char c = line[len-1]; |
200 | char c = line[len-1]; |
196 | |
201 | |
197 | if (line[0] == '+') |
202 | if (line[0] == '+') |
198 | class = "add"; |
203 | class = "add"; |
199 | else if (line[0] == '-') |
204 | else if (line[0] == '-') |
200 | class = "del"; |
205 | class = "del"; |
201 | else if (line[0] == '@') |
206 | else if (line[0] == '@') |
202 | class = "hunk"; |
207 | class = "hunk"; |
203 | |
208 | |
204 | htmlf("<div class='%s'>", class); |
209 | htmlf("<div class='%s'>", class); |
205 | line[len-1] = '\0'; |
210 | line[len-1] = '\0'; |
|