Thread (5 messages) flat view 5 messages, 3 authors, 2016-06-15

Re: [PATCH] gitweb: only display "next" links in logs if there is a next page

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:39

Possibly related (same subject, not in this thread)

Lea Wiemann [off-list ref] writes:
quoted hunk
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 <redacted>
---
 gitweb/gitweb.perl |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 308fde2..874f53a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2752,7 +2752,7 @@ sub git_print_page_nav {
 }
 
 sub format_paging_nav {
-	my ($action, $hash, $head, $page, $has_more_pages) = @_;
+	my ($action, $hash, $head, $page, $has_next_link) = @_;
 	my $paging_nav;
 
 
@@ -2770,7 +2770,7 @@ sub format_paging_nav {
 		$paging_nav .= " &sdot; prev";
 	}
 
-	if ($has_more_pages) {
+	if ($has_next_link) {
 		$paging_nav .= " &sdot; " .
 			$cgi->a({-href => href(-replay=>1, page=>$page+1),
 			         -accesskey => "n", -title => "Alt-n"}, "next");
This looks like a no-op hunk, unless format_paging_nav sub has other uses
of $has_more_pages variable.  But the copies of gitweb I have do not begin
with these lines, but they begin like this:

        sub format_paging_nav {
                my ($action, $hash, $head, $page, $nrevs) = @_;
                my $paging_nav;

On what version is your patch based on?  I checked warthog9's copy and
that also seems to be different.
quoted hunk
@@ -4661,7 +4661,7 @@ sub git_log {
 
 	my @commitlist = parse_commits($hash, 101, (100 * $page));
 
-	my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist > 99);
+	my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
 
 	git_header_html();
 	git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
@@ -5581,7 +5581,7 @@ sub git_shortlog {
 
 	my @commitlist = parse_commits($hash, 101, (100 * $page));
 
-	my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist > 99);
+	my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
 	my $next_link = '';
 	if ($#commitlist >= 100) {
 		$next_link =
I am not very good at counting, but the change looks no-op to me.  Either
the last index of the list variable is strictly larger than 99, or it is
100 or greater --- aren't they the same thing?

A bit confused I am...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help