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 <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
9b3f3de16c4a3b8414e5d49f79dda343a4ec1511
1 file changed
+7
-4
gitweb/gitweb.perl
+7
-4
@@ -3169,15 +3169,18 @@ sub parse_from_to_diffinfo {
3169
## parse to array of hashes functions
3170
3171
sub git_get_heads_list {
3172
- my $limit = shift;
3172
+ my ($limit, @classes) = @_;
3173
+ unless (@classes) {
3174
+ my $remote_heads = gitweb_check_feature('remote_heads');
3175
+ @classes = ('heads', $remote_heads ? 'remotes' : ());
3176
+ }
3177
+ my @patterns = map { "refs/$_" } @classes;
3178
my @headslist;
3179
3175
- my $remote_heads = gitweb_check_feature('remote_heads');
3176
-
3180
open my $fd, '-|', git_cmd(), 'for-each-ref',
3181
($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
3182
'--format=%(objectname) %(refname) %(subject)%00%(committer)',
3180
- 'refs/heads', ($remote_heads ? 'refs/remotes' : ())
3183
+ @patterns
3184
or return;
3185
while (my $line = <$fd>) {
3186
my %ref_item;