Skip to content

Commit

Permalink
gitweb: git_get_heads_list accepts an optional list of refs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Giuseppe Bilotta authored and Junio C Hamano committed Nov 17, 2010
1 parent 60efa24 commit 9b3f3de
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -3169,15 +3169,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;
Expand Down

0 comments on commit 9b3f3de

Please sign in to comment.