gitweb: only display "next" links in logs if there is a next page
There was a bug in the implementation of the "next" links in format_paging_nav (for log and shortlog), which caused the next links to always be displayed, even if there is no next page. This fixes it. Signed-off-by: Lea Wiemann <LeWiemann@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lea Wiemann committed
May 28, 2008 at 01:25 UTC
1f684dc01c6a45341e8e47d8393f0ef66fdfc398
1 file changed
+4
-4
gitweb/gitweb.perl
+4
-4
@@ -2676,7 +2676,7 @@ sub git_print_page_nav {
2676
}
2677
2678
sub format_paging_nav {
2679
- my ($action, $hash, $head, $page, $nrevs) = @_;
2679
+ my ($action, $hash, $head, $page, $has_next_link) = @_;
2680
my $paging_nav;
2681
2682
@@ -2694,7 +2694,7 @@ sub format_paging_nav {
2694
$paging_nav .= " ⋅ prev";
2695
}
2696
2697
- if ($nrevs >= (100 * ($page+1)-1)) {
2697
+ if ($has_next_link) {
2698
$paging_nav .= " ⋅ " .
2699
$cgi->a({-href => href(-replay=>1, page=>$page+1),
2700
-accesskey => "n", -title => "Alt-n"}, "next");
@@ -4585,7 +4585,7 @@ sub git_log {
4585
4586
my @commitlist = parse_commits($hash, 101, (100 * $page));
4587
4588
- my $paging_nav = format_paging_nav('log', $hash, $head, $page, (100 * ($page+1)));
4588
+ my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
4589
4590
git_header_html();
4591
git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
@@ -5505,7 +5505,7 @@ sub git_shortlog {
5505
5506
my @commitlist = parse_commits($hash, 101, (100 * $page));
5507
5508
- my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, (100 * ($page+1)));
5508
+ my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
5509
my $next_link = '';
5510
if ($#commitlist >= 100) {
5511
$next_link =