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

index e06c02e0ef6dc9fee79cb6703010d34cd704243bd3998090f799ad8f43a599ef..d1476401d12a47187b1fb87b9c5a4e60edecbafde766e3a0bcb3a4b176a43d07 100755 (executable)
@@ -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;
This page took 0.17443 seconds and 4 git commands to generate.