@matheusbsbs / matheus-bagliano / commits / 151602df00
Fork 0

gitweb: Add "next" link to commitdiff view

Add a kind of "next" view in the bottom part of navigation bar for "commitdiff" view. For commitdiff between two commits: (from: _commit_) For commitdiff for one single parent commit: (parent: _commit_) For commitdiff for one merge commit (merge: _commit_ _commit_ ...) For commitdiff for root (parentless) commit (initial) where _link_ denotes hyperlink. SHA1 is shortened to 7 characters on display, everything is perhaps unnecessary esc_html on display. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Oct 23, 2006 at 00:37 UTC 151602df00b8e5c5b4a8193f59a94b85f9b5aebc
1 file changed +45 -4
gitweb/gitweb.perl
+45 -4
@@ -3396,6 +3396,51 @@ sub git_commitdiff {
3396 if (!%co) {
3397 die_error(undef, "Unknown commit object");
3398 }
3399 +
3400 + # we need to prepare $formats_nav before any parameter munging
3401 + my $formats_nav;
3402 + if ($format eq 'html') {
3403 + $formats_nav =
3404 + $cgi->a({-href => href(action=>"commitdiff_plain",
3405 + hash=>$hash, hash_parent=>$hash_parent)},
3406 + "raw");
3407 +
3408 + if (defined $hash_parent) {
3409 + # commitdiff with two commits given
3410 + my $hash_parent_short = $hash_parent;
3411 + if ($hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
3412 + $hash_parent_short = substr($hash_parent, 0, 7);
3413 + }
3414 + $formats_nav .=
3415 + ' (from: ' .
3416 + $cgi->a({-href => href(action=>"commitdiff",
3417 + hash=>$hash_parent)},
3418 + esc_html($hash_parent_short)) .
3419 + ')';
3420 + } elsif (!$co{'parent'}) {
3421 + # --root commitdiff
3422 + $formats_nav .= ' (initial)';
3423 + } elsif (scalar @{$co{'parents'}} == 1) {
3424 + # single parent commit
3425 + $formats_nav .=
3426 + ' (parent: ' .
3427 + $cgi->a({-href => href(action=>"commitdiff",
3428 + hash=>$co{'parent'})},
3429 + esc_html(substr($co{'parent'}, 0, 7))) .
3430 + ')';
3431 + } else {
3432 + # merge commit
3433 + $formats_nav .=
3434 + ' (merge: ' .
3435 + join(' ', map {
3436 + $cgi->a({-href => href(action=>"commitdiff",
3437 + hash=>$_)},
3438 + esc_html(substr($_, 0, 7)));
3439 + } @{$co{'parents'}} ) .
3440 + ')';
3441 + }
3442 + }
3443 +
3444 if (!defined $hash_parent) {
3445 $hash_parent = $co{'parent'} || '--root';
3446 }
@@ -3434,10 +3479,6 @@ sub git_commitdiff {
3479 if ($format eq 'html') {
3480 my $refs = git_get_references();
3481 my $ref = format_ref_marker($refs, $co{'id'});
3437 - my $formats_nav =
3438 - $cgi->a({-href => href(action=>"commitdiff_plain",
3439 - hash=>$hash, hash_parent=>$hash_parent)},
3440 - "raw");
3482
3483 git_header_html(undef, $expires);
3484 git_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);