@matheusbsbs / matheus-bagliano / commits / c9d193dffb
Fork 0

gitweb: Add "next" link to commit view

Add a kind of "next" view in the bottom part of navigation bar for "commit" view, similar to what was added for "commitdiff" view in commit 151602df00b8e5c5b4a8193f59a94b85f9b5aebc 'gitweb: Add "next" link to commitdiff view' For "commit" view for single parent commit: (parent: _commit_) For "commit" view for merge (multi-parent) commit: (merge: _commit_ _commit_ ...) For "commit" view for root (parentless) commit (initial) where _link_ denotes hyperlink. SHA1 of commit is shortened to 7 characters on display. While at it, remove leftovers from commit cae1862a by Petr Baudis: 'gitweb: More per-view navigation bar links' namely the "blame" link if there exist $file_name and commit has a parent; it was added in git_commit probably by mistake. The rest of what mentioned commit added for git_commit was removed in commit 6e0e92fda893311ff5af91836e5007bf6bbd4a21 by Luben Tuikov: 'gitweb: Do not print "log" and "shortlog" redundantly in commit view' (which should have probably removed also this "blame" link removed now). Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jakub Narebski committed Dec 15, 2006 at 21:57 UTC c9d193dffbeaf0f106e712879c3ce3d2a4846157
1 file changed +29 -9
gitweb/gitweb.perl
+29 -9
@@ -3572,8 +3572,34 @@ sub git_commit {
3572 my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
3573 my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
3574
3575 - my $parent = $co{'parent'};
3576 - my $parents = $co{'parents'};
3575 + my $parent = $co{'parent'};
3576 + my $parents = $co{'parents'}; # listref
3577 +
3578 + # we need to prepare $formats_nav before any parameter munging
3579 + my $formats_nav;
3580 + if (!defined $parent) {
3581 + # --root commitdiff
3582 + $formats_nav .= '(initial)';
3583 + } elsif (@$parents == 1) {
3584 + # single parent commit
3585 + $formats_nav .=
3586 + '(parent: ' .
3587 + $cgi->a({-href => href(action=>"commit",
3588 + hash=>$parent)},
3589 + esc_html(substr($parent, 0, 7))) .
3590 + ')';
3591 + } else {
3592 + # merge commit
3593 + $formats_nav .=
3594 + '(merge: ' .
3595 + join(' ', map {
3596 + $cgi->a({-href => href(action=>"commitdiff",
3597 + hash=>$_)},
3598 + esc_html(substr($_, 0, 7)));
3599 + } @$parents ) .
3600 + ')';
3601 + }
3602 +
3603 if (!defined $parent) {
3604 $parent = "--root";
3605 }
@@ -3597,16 +3623,10 @@ sub git_commit {
3623
3624 my $have_snapshot = gitweb_have_snapshot();
3625
3600 - my @views_nav = ();
3601 - if (defined $file_name && defined $co{'parent'}) {
3602 - push @views_nav,
3603 - $cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)},
3604 - "blame");
3605 - }
3626 git_header_html(undef, $expires);
3627 git_print_page_nav('commit', '',
3628 $hash, $co{'tree'}, $hash,
3609 - join (' | ', @views_nav));
3629 + $formats_nav);
3630
3631 if (defined $co{'parent'}) {
3632 git_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);