gitweb: introduce remote_heads feature
With this feature enabled, remote heads are retrieved (and displayed) when getting (and displaying) the heads list. Typical usage would be for local repository browsing, e.g. by using git-instaweb (or even a more permanent gitweb setup), to check the repository status and the relation between tracking branches and the originating remotes. 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
60efa2451e46810bdf7da6a31758c779de8ff4f7
1 file changed
+16
-2
gitweb/gitweb.perl
+16
-2
@@ -493,6 +493,18 @@ our %feature = (
493
'sub' => sub { feature_bool('highlight', @_) },
494
'override' => 0,
495
'default' => [0]},
496
+
497
+ # Enable displaying of remote heads in the heads list
498
+
499
+ # To enable system wide have in $GITWEB_CONFIG
500
+ # $feature{'remote_heads'}{'default'} = [1];
501
+ # To have project specific config enable override in $GITWEB_CONFIG
502
+ # $feature{'remote_heads'}{'override'} = 1;
503
+ # and in project config gitweb.remote_heads = 0|1;
504
+ 'remote_heads' => {
505
+ 'sub' => sub { feature_bool('remote_heads', @_) },
506
+ 'override' => 0,
507
+ 'default' => [0]},
508
);
509
510
sub gitweb_get_feature {
@@ -3160,10 +3172,12 @@ sub git_get_heads_list {
3172
my $limit = shift;
3173
my @headslist;
3174
3175
+ my $remote_heads = gitweb_check_feature('remote_heads');
3176
+
3177
open my $fd, '-|', git_cmd(), 'for-each-ref',
3178
($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
3179
'--format=%(objectname) %(refname) %(subject)%00%(committer)',
3166
- 'refs/heads'
3180
+ 'refs/heads', ($remote_heads ? 'refs/remotes' : ())
3181
or return;
3182
while (my $line = <$fd>) {
3183
my %ref_item;
@@ -3174,7 +3188,7 @@ sub git_get_heads_list {
3188
my ($committer, $epoch, $tz) =
3189
($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
3190
$ref_item{'fullname'} = $name;
3177
- $name =~ s!^refs/heads/!!;
3191
+ $name =~ s!^refs/(?:head|remote)s/!!;
3192
3193
$ref_item{'name'} = $name;
3194
$ref_item{'id'} = $hash;