diff options
Diffstat (limited to 'ui-diff.c')
| -rw-r--r-- | ui-diff.c | 83 |
1 files changed, 54 insertions, 29 deletions
| @@ -169,7 +169,7 @@ static void inspect_filepair(struct diff_filepair *pair) | |||
| 169 | void cgit_print_diffstat(const unsigned char *old_sha1, | 169 | void 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 | ||
| 283 | static 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 | |||
| 296 | static void filepair_cb(struct diff_filepair *pair) | 270 | static void filepair_cb(struct diff_filepair *pair) |
| 297 | { | 271 | { |
| 298 | unsigned long old_size = 0; | 272 | unsigned long old_size = 0; |
| @@ -332,7 +306,56 @@ static void filepair_cb(struct diff_filepair *pair) | |||
| 332 | cgit_ssdiff_footer(); | 306 | cgit_ssdiff_footer(); |
| 333 | } | 307 | } |
| 334 | 308 | ||
| 335 | void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefix) | 309 | void 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.ssdiff; | ||
| 345 | if (!curr && ctx.cfg.ssdiff) | ||
| 346 | curr = 1; | ||
| 347 | html_intoption(0, "unified", curr); | ||
| 348 | html_intoption(1, "ssdiff", curr); | ||
| 349 | html("</select></td></tr>"); | ||
| 350 | html("<tr><td/><td class='ctrl'>"); | ||
| 351 | html("<noscript><input type='submit' value='reload'/></noscript>"); | ||
| 352 | html("</td></tr></table>"); | ||
| 353 | html("</form>"); | ||
| 354 | html("</div>"); | ||
| 355 | } | ||
| 356 | |||
| 357 | void cgit_print_diff(const char *new_rev, const char *old_rev, | ||
| 358 | const char *prefix, int show_ctrls) | ||
| 336 | { | 359 | { |
| 337 | enum object_type type; | 360 | enum object_type type; |
| 338 | unsigned long size; | 361 | unsigned long size; |
| @@ -375,7 +398,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi | |||
| 375 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) | 398 | if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff)) |
| 376 | use_ssdiff = 1; | 399 | use_ssdiff = 1; |
| 377 | 400 | ||
| 378 | print_ssdiff_link(); | 401 | if (show_ctrls) |
| 402 | cgit_print_diff_ctrls(); | ||
| 403 | |||
| 379 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); | 404 | cgit_print_diffstat(old_rev_sha1, new_rev_sha1, prefix); |
| 380 | 405 | ||
| 381 | if (use_ssdiff) { | 406 | if (use_ssdiff) { |
