gitweb: separate heads and remotes lists
We specialize the 'heads' action to only display local branches, and introduce a 'remotes' action to display the remote branches (only available when the remotes_head feature is enabled). Mirroring this, we also split the heads list in summary view into local and remote lists, each linking to the appropriate action. The git_get_heads_list now defaults to 'heads' only, regardless of whether the remote heads feature is active or not. Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Acked-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Giuseppe Bilotta committed
Nov 11, 2010 at 13:26 UTC
00fa6fef631edeb5e0e34b7748c07882ec0e51d7
1 file changed
+27
-4
gitweb/gitweb.perl
+27
-4
@@ -719,6 +719,7 @@ our %actions = (
719
"log" => \&git_log,
720
"patch" => \&git_patch,
721
"patches" => \&git_patches,
722
+ "remotes" => \&git_remotes,
723
"rss" => \&git_rss,
724
"atom" => \&git_atom,
725
"search" => \&git_search,
@@ -3170,10 +3171,7 @@ sub parse_from_to_diffinfo {
3171
3172
sub git_get_heads_list {
3173
my ($limit, @classes) = @_;
3173
- unless (@classes) {
3174
- my $remote_heads = gitweb_check_feature('remote_heads');
3175
- @classes = ('heads', $remote_heads ? 'remotes' : ());
3176
- }
3174
+ @classes = ('heads') unless @classes;
3175
my @patterns = map { "refs/$_" } @classes;
3176
my @headslist;
3177
@@ -5126,6 +5124,7 @@ sub git_summary {
5124
my %co = parse_commit("HEAD");
5125
my %cd = %co ? parse_date($co{'committer_epoch'}, $co{'committer_tz'}) : ();
5126
my $head = $co{'id'};
5127
+ my $remote_heads = gitweb_check_feature('remote_heads');
5128
5129
my $owner = git_get_project_owner($project);
5130
@@ -5134,6 +5133,7 @@ sub git_summary {
5133
# there are more ...
5134
my @taglist = git_get_tags_list(16);
5135
my @headlist = git_get_heads_list(16);
5136
+ my @remotelist = $remote_heads ? git_get_heads_list(16, 'remotes') : ();
5137
my @forklist;
5138
my $check_forks = gitweb_check_feature('forks');
5139
@@ -5211,6 +5211,13 @@ sub git_summary {
5211
$cgi->a({-href => href(action=>"heads")}, "..."));
5212
}
5213
5214
+ if (@remotelist) {
5215
+ git_print_header_div('remotes');
5216
+ git_heads_body(\@remotelist, $head, 0, 15,
5217
+ $#remotelist <= 15 ? undef :
5218
+ $cgi->a({-href => href(action=>"remotes")}, "..."));
5219
+ }
5220
+
5221
if (@forklist) {
5222
git_print_header_div('forks');
5223
git_project_list_body(\@forklist, 'age', 0, 15,
@@ -5525,6 +5532,22 @@ sub git_heads {
5532
git_footer_html();
5533
}
5534
5535
+sub git_remotes {
5536
+ gitweb_check_feature('remote_heads')
5537
+ or die_error(403, "Remote heads view is disabled");
5538
+
5539
+ my $head = git_get_head_hash($project);
5540
+ git_header_html();
5541
+ git_print_page_nav('','', $head,undef,$head);
5542
+ git_print_header_div('summary', $project);
5543
+
5544
+ my @remotelist = git_get_heads_list(undef, 'remotes');
5545
+ if (@remotelist) {
5546
+ git_heads_body(\@remotelist, $head);
5547
+ }
5548
+ git_footer_html();
5549
+}
5550
+
5551
sub git_blob_plain {
5552
my $type = shift;
5553
my $expires;