about summary refs log tree commit diff stats
path: root/ui-diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-diff.c')
-rw-r--r--ui-diff.c81
1 files changed, 52 insertions, 29 deletions
diff --git a/ui-diff.c b/ui-diff.c index f8782df..c6bad63 100644 --- a/ui-diff.c +++ b/ui-diff.c
@@ -169,7 +169,7 @@ static void inspect_filepair(struct diff_filepair *pair)
169void cgit_print_diffstat(const unsigned char *old_sha1, 169void cgit_print_diffstat(const unsigned char *old_sha1,
170 const unsigned char *new_sha1, const char *prefix) 170 const unsigned char *new_sha1, const char *prefix)
171{ 171{
172 int i, save_context = ctx.qry.context; 172 int i;
173 173
174 html("<div class='diffstat-header'>"); 174 html("<div class='diffstat-header'>");
175 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, 175 cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1,
@@ -179,19 +179,6 @@ void cgit_print_diffstat(const unsigned char *old_sha1,
179 html_txt(prefix); 179 html_txt(prefix);
180 html("')"); 180 html("')");
181 } 181 }
182 html(" (");
183 ctx.qry.context = (save_context > 0 ? save_context : 3) << 1;
184 cgit_self_link("more", NULL, NULL, &ctx);
185 html("/");
186 ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1;
187 cgit_self_link("less", NULL, NULL, &ctx);
188 ctx.qry.context = save_context;
189 html(" context)");
190 html(" (");
191 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
192 cgit_self_link(ctx.qry.ignorews ? "ignore" : "show", NULL, NULL, &ctx);
193 ctx.qry.ignorews = (ctx.qry.ignorews + 1) % 2;
194 html(" whitespace changes)");
195 html("</div>"); 182 html("</div>");
196 html("<table summary='diffstat' class='diffstat'>"); 183 html("<table summary='diffstat' class='diffstat'>");
197 max_changes = 0; 184 max_changes = 0;
@@ -280,19 +267,6 @@ static void header(unsigned char *sha1, char *path1, int mode1,
280 html("</div>"); 267 html("</div>");
281} 268}
282 269
283static void print_ssdiff_link()
284{
285 if (!strcmp(ctx.qry.page, "diff")) {
286 if (use_ssdiff)
287 cgit_diff_link("Unidiff", NULL, NULL, ctx.qry.head,
288 ctx.qry.sha1, ctx.qry.sha2, ctx.qry.path, 1);
289 else
290 cgit_diff_link("Side-by-side diff", NULL, NULL,
291 ctx.qry.head, ctx.qry.sha1,
292 ctx.qry.sha2, ctx.qry.path, 1);
293 }
294}
295
296static void filepair_cb(struct diff_filepair *pair) 270static void filepair_cb(struct diff_filepair *pair)
297{ 271{
298 unsigned long old_size = 0; 272 unsigned long old_size = 0;
@@ -332,7 +306,54 @@ static void filepair_cb(struct diff_filepair *pair)
332 cgit_ssdiff_footer(); 306 cgit_ssdiff_footer();
333} 307}
334 308
335void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) 309void cgit_print_diff_ctrls()
310{
311 int i, curr;
312
313 html("<div class='cgit-panel'>");
314 html("<b>diff options</b>");
315 html("<form method='get' action='.'>");
316 cgit_add_hidden_formfields(1, 0, ctx.qry.page);
317 html("<table>");
318 html("<tr><td colspan='2'/></tr>");
319 html("<tr>");
320 html("<td class='label'>context:</td>");
321 html("<td class='ctrl'>");
322 html("<select name='context' onchange='this.form.submit();'>");
323 curr = ctx.qry.context;
324 if (!curr)
325 curr = 3;
326 for (i = 1; i <= 10; i++)
327 html_intoption(i, fmt("%d", i), curr);
328 for (i = 15; i <= 40; i += 5)
329 html_intoption(i, fmt("%d", i), curr);
330 html("</select>");
331 html("</td>");
332 html("</tr><tr>");
333 html("<td class='label'>space:</td>");
334 html("<td class='ctrl'>");
335 html("<select name='ignorews' onchange='this.form.submit();'>");
336 html_intoption(0, "include", ctx.qry.ignorews);
337 html_intoption(1, "ignore", ctx.qry.ignorews);
338 html("</select>");
339 html("</td>");
340 html("</tr><tr>");
341 html("<td class='label'>mode:</td>");
342 html("<td class='ctrl'>");
343 html("<select name='ss' onchange='this.form.submit();'>");
344 curr = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;
345 html_intoption(0, "unified", curr);
346 html_intoption(1, "ssdiff", curr);
347 html("</select></td></tr>");
348 html("<tr><td/><td class='ctrl'>");
349 html("<noscript><input type='submit' value='reload'/></noscript>");
350 html("</td></tr></table>");
351 html("</form>");
352 html("</div>");
353}
354
355void cgit_print_diff(const char *new_rev, const char *old_rev,
356 const char *prefix, int show_ctrls)
336{ 357{
337 enum object_type type; 358 enum object_type type;
338 unsigned long size; 359 unsigned long size;
@@ -374,7 +395,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi
374 395
375 use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff; 396 use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff;
376 397
377 print_ssdiff_link(); 398 if (show_ctrls)
399 cgit_print_diff_ctrls();
400
378 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); 401 cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix);
379 402
380 if (use_ssdiff) { 403 if (use_ssdiff) {