git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: Show '...' links in "summary" view only if there are more items

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 19, 2006, 11:14 UTC
Message-ID
<200612191214.58474.jnareb@gmail.com>
In-Reply-To
<200612190159.24173.jnareb@gmail.com>

Show "..." links in "summary" view to shortlog, heads (if there are any), and tags (if there are any) only if there are more items to show than shown already.

This means that "..." link is shown below shortened shortlog if there are more than 16 commits, "..." link below shortened heads list if there are more than 16 heads refs (16 branches), "..." link below shortened tags list if there are more than 16 tags.

Added some comments.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Jakub Narebski wrote:
Show 6 quoted lines
> Junio C Hamano wrote:
>> Jakub Narebski <jnareb@gmail.com> writes:
>> 
>>> Actually, that is needed to implement checking if we have more than
>>> the number of commits to show to add '...' at the end only if there
>>> are some commits which we don't show.
[...]
Show 6 quoted lines
>> By the way, I wonder how that $extra is omitted when $revlist is
>> longer than $to; it should be a trivial fix but it seems to me
>> that it is always spitted out with the current code.
> 
> We should check if we want to omit $extra, either in caller or
> in callee, the *_body subroutine itself.
And now it is done.

Slightly tested: on my clone (copy) of git repository, which more than 16 commits, more than 16 heads (most temporary, and no longer worked on, few tracking branches) and more than 16 heads show all "..." as it should. Test of freshly created repository shown no "..." for commits (only one commit), no "..." for heads (only one default head 'master'), and no tags list (no tags at all).

By the way, I have _NOT_ applied Robert Fitzsimons patch, but they (this patch and Robert patch) should be not in conflict if we remove last chunk of Robert's patch (this changing --count=17 to --count=15 in git_summary).

 gitweb/gitweb.perl |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4059894..73877f2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2915,8 +2915,9 @@ sub git_summary {
 	my $owner = git_get_project_owner($project);
 
 	my $refs = git_get_references();
-	my @taglist  = git_get_tags_list(15);
-	my @headlist = git_get_heads_list(15);
+	# we need to request one more than 16 (0..15) to check if those 16 are all
+	my @taglist  = git_get_tags_list(17);
+	my @headlist = git_get_heads_list(17);
 	my @forklist;
 	my ($check_forks) = gitweb_check_feature('forks');
 
@@ -2952,6 +2953,7 @@ sub git_summary {
 		}
 	}
 
+	# we need to request one more than 16 (0..15) to check if those 16 are all
 	open my $fd, "-|", git_cmd(), "rev-list", "--max-count=17",
 		git_get_head_hash($project), "--"
 		or die_error(undef, "Open git-rev-list failed");
@@ -2959,17 +2961,20 @@ sub git_summary {
 	close $fd;
 	git_print_header_div('shortlog');
 	git_shortlog_body(\@revlist, 0, 15, $refs,
+	                  $#revlist <=  15 ? undef :
 	                  $cgi->a({-href => href(action=>"shortlog")}, "..."));
 
 	if (@taglist) {
 		git_print_header_div('tags');
 		git_tags_body(\@taglist, 0, 15,
+		              $#taglist <=  15 ? undef :
 		              $cgi->a({-href => href(action=>"tags")}, "..."));
 	}
 
 	if (@headlist) {
 		git_print_header_div('heads');
 		git_heads_body(\@headlist, $head, 0, 15,
+		               $#headlist <= 15 ? undef :
 		               $cgi->a({-href => href(action=>"heads")}, "..."));
 	}
 
Previous: Junio C HamanoNext: Robert Fitzsimons
Message 6 of 11 in “Small optimizations to gitweb”
  1. Small optimizations to gitwebRobert Fitzsimons, Dec 18, 2006
  2. Jakub NarebskiDec 18, 2006
  3. Junio C HamanoDec 18, 2006
  4. Jakub NarebskiDec 19, 2006
  5. Junio C HamanoDec 19, 2006
  6. gitweb: Show '...' links in "summary" view only if there are more itemsJakub Narebski, Dec 19, 2006
  7. gitweb: Show '...' links in "summary" view only if there are more itemsRobert Fitzsimons, Dec 19, 2006
  8. Jakub NarebskiDec 19, 2006
  9. Robert FitzsimonsDec 19, 2006
  10. Jakub NarebskiDec 19, 2006
  11. Junio C HamanoDec 19, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.