gitweb: Show '...' links in "summary" view only if there are more items
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. Modified patch from Jakub to to apply cleanly to master, also preform the same "..." link logic to the forks list. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Robert Fitzsimons <robfitz@273k.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Robert Fitzsimons committed
Dec 19, 2006 at 12:08 UTC
313ce8cee665447e4476d7e8985b270346a8e5a1
1 file changed
+9
-2
gitweb/gitweb.perl
+9
-2
@@ -2915,8 +2915,10 @@ sub git_summary {
2915
my $owner = git_get_project_owner($project);
2916
2917
my $refs = git_get_references();
2918
- my @taglist = git_get_tags_list(15);
2919
- my @headlist = git_get_heads_list(15);
2918
+ # These get_*_list functions return one more to allow us to see if
2919
+ # there are more ...
2920
+ my @taglist = git_get_tags_list(16);
2921
+ my @headlist = git_get_heads_list(16);
2922
my @forklist;
2923
my ($check_forks) = gitweb_check_feature('forks');
2924
@@ -2952,6 +2954,8 @@ sub git_summary {
2954
}
2955
}
2956
2957
+ # we need to request one more than 16 (0..15) to check if
2958
+ # those 16 are all
2959
open my $fd, "-|", git_cmd(), "rev-list", "--max-count=17",
2960
git_get_head_hash($project), "--"
2961
or die_error(undef, "Open git-rev-list failed");
@@ -2959,17 +2963,20 @@ sub git_summary {
2963
close $fd;
2964
git_print_header_div('shortlog');
2965
git_shortlog_body(\@revlist, 0, 15, $refs,
2966
+ $#revlist <= 15 ? undef :
2967
$cgi->a({-href => href(action=>"shortlog")}, "..."));
2968
2969
if (@taglist) {
2970
git_print_header_div('tags');
2971
git_tags_body(\@taglist, 0, 15,
2972
+ $#taglist <= 15 ? undef :
2973
$cgi->a({-href => href(action=>"tags")}, "..."));
2974
}
2975
2976
if (@headlist) {
2977
git_print_header_div('heads');
2978
git_heads_body(\@headlist, $head, 0, 15,
2979
+ $#headlist <= 15 ? undef :
2980
$cgi->a({-href => href(action=>"heads")}, "..."));
2981
}
2982