From: Giuseppe Bilotta Date: Thu, 11 Nov 2010 12:26:10 +0000 (+0100) Subject: gitweb: git_get_heads_list accepts an optional list of refs X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/bc3fdc02f215ec2408fd9233e7d410f192f0d0b566ef7909413bf2479635b3f6?ds=sidebyside;hp=b765f648f6e996f045b6dea97c291e59d0a092ec7c3d3f1e2d38adb76081e331 gitweb: git_get_heads_list accepts an optional list of refs git_get_heads_list(limit, class1, class2, ...) can now be used to retrieve refs/class1, refs/class2 etc. Defaults to ('heads', 'remotes') or ('heads') depending on whether the 'remote_heads' feature is enabled or not. Signed-off-by: Giuseppe Bilotta Acked-by: Jakub Narebski Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index e06c02e..d147640 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -3168,15 +3168,18 @@ sub parse_from_to_diffinfo { ## parse to array of hashes functions sub git_get_heads_list { - my $limit = shift; + my ($limit, @classes) = @_; + unless (@classes) { + my $remote_heads = gitweb_check_feature('remote_heads'); + @classes = ('heads', $remote_heads ? 'remotes' : ()); + } + my @patterns = map { "refs/$_" } @classes; 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', ($remote_heads ? 'refs/remotes' : ()) + @patterns or return; while (my $line = <$fd>) { my %ref_item;