diff options
| author | John Keeping | 2015-08-14 12:47:14 +0100 |
|---|---|---|
| committer | Jason A. Donenfeld | 2015-08-14 15:46:51 +0200 |
| commit | 3b220eb22ded98851ca9dee7c3c3e3b0fd02c49b (patch) | |
| tree | 77573441ad15b57a4f62ecaac847461fd0e7e49f /ui-diff.c | |
| parent | c53a15c77a6763b4d6fefb033923ba7493b884a2 (diff) | |
| download | cgit-3b220eb22ded98851ca9dee7c3c3e3b0fd02c49b.tar.gz cgit-3b220eb22ded98851ca9dee7c3c3e3b0fd02c49b.tar.bz2 cgit-3b220eb22ded98851ca9dee7c3c3e3b0fd02c49b.zip | |
diff: move layout to page function
The existing "show_ctrls" flag is used to control whether we are running
in an existing page or control the page ourselves.
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-diff.c')
| -rw-r--r-- | ui-diff.c | 19 |
1 files changed, 14 insertions, 5 deletions
| @@ -403,19 +403,22 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, | |||
| 403 | if (!new_rev) | 403 | if (!new_rev) |
| 404 | new_rev = ctx.qry.head; | 404 | new_rev = ctx.qry.head; |
| 405 | if (get_sha1(new_rev, new_rev_sha1)) { | 405 | if (get_sha1(new_rev, new_rev_sha1)) { |
| 406 | cgit_print_error("Bad object name: %s", new_rev); | 406 | cgit_print_error_page(404, "Not found", |
| 407 | "Bad object name: %s", new_rev); | ||
| 407 | return; | 408 | return; |
| 408 | } | 409 | } |
| 409 | commit = lookup_commit_reference(new_rev_sha1); | 410 | commit = lookup_commit_reference(new_rev_sha1); |
| 410 | if (!commit || parse_commit(commit)) { | 411 | if (!commit || parse_commit(commit)) { |
| 411 | cgit_print_error("Bad commit: %s", sha1_to_hex(new_rev_sha1)); | 412 | cgit_print_error_page(404, "Not found", |
| 413 | "Bad commit: %s", sha1_to_hex(new_rev_sha1)); | ||
| 412 | return; | 414 | return; |
| 413 | } | 415 | } |
| 414 | new_tree_sha1 = commit->tree->object.sha1; | 416 | new_tree_sha1 = commit->tree->object.sha1; |
| 415 | 417 | ||
| 416 | if (old_rev) { | 418 | if (old_rev) { |
| 417 | if (get_sha1(old_rev, old_rev_sha1)) { | 419 | if (get_sha1(old_rev, old_rev_sha1)) { |
| 418 | cgit_print_error("Bad object name: %s", old_rev); | 420 | cgit_print_error_page(404, "Not found", |
| 421 | "Bad object name: %s", old_rev); | ||
| 419 | return; | 422 | return; |
| 420 | } | 423 | } |
| 421 | } else if (commit->parents && commit->parents->item) { | 424 | } else if (commit->parents && commit->parents->item) { |
| @@ -427,7 +430,8 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, | |||
| 427 | if (!is_null_sha1(old_rev_sha1)) { | 430 | if (!is_null_sha1(old_rev_sha1)) { |
| 428 | commit2 = lookup_commit_reference(old_rev_sha1); | 431 | commit2 = lookup_commit_reference(old_rev_sha1); |
| 429 | if (!commit2 || parse_commit(commit2)) { | 432 | if (!commit2 || parse_commit(commit2)) { |
| 430 | cgit_print_error("Bad commit: %s", sha1_to_hex(old_rev_sha1)); | 433 | cgit_print_error_page(404, "Not found", |
| 434 | "Bad commit: %s", sha1_to_hex(old_rev_sha1)); | ||
| 431 | return; | 435 | return; |
| 432 | } | 436 | } |
| 433 | old_tree_sha1 = commit2->tree->object.sha1; | 437 | old_tree_sha1 = commit2->tree->object.sha1; |
| @@ -460,8 +464,10 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, | |||
| 460 | difftype = ctx.qry.has_difftype ? ctx.qry.difftype : ctx.cfg.difftype; | 464 | difftype = ctx.qry.has_difftype ? ctx.qry.difftype : ctx.cfg.difftype; |
| 461 | use_ssdiff = difftype == DIFF_SSDIFF; | 465 | use_ssdiff = difftype == DIFF_SSDIFF; |
| 462 | 466 | ||
| 463 | if (show_ctrls) | 467 | if (show_ctrls) { |
| 468 | cgit_print_layout_start(); | ||
| 464 | cgit_print_diff_ctrls(); | 469 | cgit_print_diff_ctrls(); |
| 470 | } | ||
| 465 | 471 | ||
| 466 | /* | 472 | /* |
| 467 | * Clicking on a link to a file in the diff stat should show a diff | 473 | * Clicking on a link to a file in the diff stat should show a diff |
| @@ -489,4 +495,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, | |||
| 489 | if (!use_ssdiff) | 495 | if (!use_ssdiff) |
| 490 | html("</td></tr>"); | 496 | html("</td></tr>"); |
| 491 | html("</table>"); | 497 | html("</table>"); |
| 498 | |||
| 499 | if (show_ctrls) | ||
| 500 | cgit_print_layout_end(); | ||
| 492 | } | 501 | } |
