]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: introduce remote_heads feature
authorGiuseppe Bilotta <redacted>
Thu, 11 Nov 2010 12:26:09 +0000 (13:26 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:30 +0000 (00:51 -0400)
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 <redacted>
Acked-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 26d0170b3216e4d707da214a67b36551de76e79752465f65de0c58a7abca5bca..e06c02e0ef6dc9fee79cb6703010d34cd704243bd3998090f799ad8f43a599ef 100755 (executable)
@@ -492,6 +492,18 @@ our %feature = (
                'sub' => sub { feature_bool('highlight', @_) },
                'override' => 0,
                'default' => [0]},
+
+       # Enable displaying of remote heads in the heads list
+
+       # To enable system wide have in $GITWEB_CONFIG
+       # $feature{'remote_heads'}{'default'} = [1];
+       # To have project specific config enable override in $GITWEB_CONFIG
+       # $feature{'remote_heads'}{'override'} = 1;
+       # and in project config gitweb.remote_heads = 0|1;
+       'remote_heads' => {
+               'sub' => sub { feature_bool('remote_heads', @_) },
+               'override' => 0,
+               'default' => [0]},
 );
 
 sub gitweb_get_feature {
@@ -3159,10 +3171,12 @@ sub git_get_heads_list {
        my $limit = shift;
        my @headslist;
 
+       my $remote_heads = gitweb_check_feature('remote_heads');
+
        open my $fd, '-|', git_cmd(), 'for-each-ref',
                ($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
                '--format=%(objectname) %(refname) %(subject)%00%(committer)',
-               'refs/heads'
+               'refs/heads', ($remote_heads ? 'refs/remotes' : ())
                or return;
        while (my $line = <$fd>) {
                my %ref_item;
@@ -3173,7 +3187,7 @@ sub git_get_heads_list {
                my ($committer, $epoch, $tz) =
                        ($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);
                $ref_item{'fullname'}  = $name;
-               $name =~ s!^refs/heads/!!;
+               $name =~ s!^refs/(?:head|remote)s/!!;
 
                $ref_item{'name'}  = $name;
                $ref_item{'id'}    = $hash;
This page took 0.263132 seconds and 4 git commands to generate.