gitweb: Make git_get_refs_list do work of git_get_references
Make git_get_refs_list do also work of git_get_references, to avoid calling git-peek-remote twice. Change meaning of git_get_refs_list meaning: it is now type, and not a full path, e.g. we now use git_get_refs_list("heads") instead of former git_get_refs_list("refs/heads"). Modify git_summary to use only one call to git_get_refs_list instead of one call to git_get_references and two to git_get_refs_list. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
9704d75ddc
commit
120ddde2a8
@ -1134,7 +1134,8 @@ sub parse_ls_tree_line ($;%) {
|
|||||||
## parse to array of hashes functions
|
## parse to array of hashes functions
|
||||||
|
|
||||||
sub git_get_refs_list {
|
sub git_get_refs_list {
|
||||||
my $ref_dir = shift;
|
my $type = shift || "";
|
||||||
|
my %refs;
|
||||||
my @reflist;
|
my @reflist;
|
||||||
|
|
||||||
my @refs;
|
my @refs;
|
||||||
@ -1142,14 +1143,21 @@ sub git_get_refs_list {
|
|||||||
or return;
|
or return;
|
||||||
while (my $line = <$fd>) {
|
while (my $line = <$fd>) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
if ($line =~ m/^([0-9a-fA-F]{40})\t$ref_dir\/?([^\^]+)$/) {
|
if ($line =~ m/^([0-9a-fA-F]{40})\trefs\/($type\/?([^\^]+))(\^\{\})?$/) {
|
||||||
push @refs, { hash => $1, name => $2 };
|
if (defined $refs{$1}) {
|
||||||
} elsif ($line =~ m/^[0-9a-fA-F]{40}\t$ref_dir\/?(.*)\^\{\}$/ &&
|
push @{$refs{$1}}, $2;
|
||||||
$1 eq $refs[-1]{'name'}) {
|
} else {
|
||||||
# most likely a tag is followed by its peeled
|
$refs{$1} = [ $2 ];
|
||||||
# (deref) one, and when that happens we know the
|
}
|
||||||
# previous one was of type 'tag'.
|
|
||||||
$refs[-1]{'type'} = "tag";
|
if (! $4) { # unpeeled, direct reference
|
||||||
|
push @refs, { hash => $1, name => $3 }; # without type
|
||||||
|
} elsif ($3 eq $refs[-1]{'name'}) {
|
||||||
|
# most likely a tag is followed by its peeled
|
||||||
|
# (deref) one, and when that happens we know the
|
||||||
|
# previous one was of type 'tag'.
|
||||||
|
$refs[-1]{'type'} = "tag";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close $fd;
|
close $fd;
|
||||||
@ -1165,7 +1173,7 @@ sub git_get_refs_list {
|
|||||||
}
|
}
|
||||||
# sort refs by age
|
# sort refs by age
|
||||||
@reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
|
@reflist = sort {$b->{'epoch'} <=> $a->{'epoch'}} @reflist;
|
||||||
return \@reflist;
|
return (\@reflist, \%refs);
|
||||||
}
|
}
|
||||||
|
|
||||||
## ----------------------------------------------------------------------
|
## ----------------------------------------------------------------------
|
||||||
@ -2129,14 +2137,14 @@ sub git_tags_body {
|
|||||||
|
|
||||||
sub git_heads_body {
|
sub git_heads_body {
|
||||||
# uses global variable $project
|
# uses global variable $project
|
||||||
my ($taglist, $head, $from, $to, $extra) = @_;
|
my ($headlist, $head, $from, $to, $extra) = @_;
|
||||||
$from = 0 unless defined $from;
|
$from = 0 unless defined $from;
|
||||||
$to = $#{$taglist} if (!defined $to || $#{$taglist} < $to);
|
$to = $#{$headlist} if (!defined $to || $#{$headlist} < $to);
|
||||||
|
|
||||||
print "<table class=\"heads\" cellspacing=\"0\">\n";
|
print "<table class=\"heads\" cellspacing=\"0\">\n";
|
||||||
my $alternate = 0;
|
my $alternate = 0;
|
||||||
for (my $i = $from; $i <= $to; $i++) {
|
for (my $i = $from; $i <= $to; $i++) {
|
||||||
my $entry = $taglist->[$i];
|
my $entry = $headlist->[$i];
|
||||||
my %tag = %$entry;
|
my %tag = %$entry;
|
||||||
my $curr = $tag{'id'} eq $head;
|
my $curr = $tag{'id'} eq $head;
|
||||||
if ($alternate) {
|
if ($alternate) {
|
||||||
@ -2306,7 +2314,19 @@ sub git_summary {
|
|||||||
|
|
||||||
my $owner = git_get_project_owner($project);
|
my $owner = git_get_project_owner($project);
|
||||||
|
|
||||||
my $refs = git_get_references();
|
my ($reflist, $refs) = git_get_refs_list();
|
||||||
|
|
||||||
|
my @taglist;
|
||||||
|
my @headlist;
|
||||||
|
foreach my $ref (@$reflist) {
|
||||||
|
if ($ref->{'name'} =~ s!^heads/!!) {
|
||||||
|
push @headlist, $ref;
|
||||||
|
} else {
|
||||||
|
$ref->{'name'} =~ s!^tags/!!;
|
||||||
|
push @taglist, $ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
git_header_html();
|
git_header_html();
|
||||||
git_print_page_nav('summary','', $head);
|
git_print_page_nav('summary','', $head);
|
||||||
|
|
||||||
@ -2336,17 +2356,15 @@ sub git_summary {
|
|||||||
git_shortlog_body(\@revlist, 0, 15, $refs,
|
git_shortlog_body(\@revlist, 0, 15, $refs,
|
||||||
$cgi->a({-href => href(action=>"shortlog")}, "..."));
|
$cgi->a({-href => href(action=>"shortlog")}, "..."));
|
||||||
|
|
||||||
my $taglist = git_get_refs_list("refs/tags");
|
if (@taglist) {
|
||||||
if (defined @$taglist) {
|
|
||||||
git_print_header_div('tags');
|
git_print_header_div('tags');
|
||||||
git_tags_body($taglist, 0, 15,
|
git_tags_body(\@taglist, 0, 15,
|
||||||
$cgi->a({-href => href(action=>"tags")}, "..."));
|
$cgi->a({-href => href(action=>"tags")}, "..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
my $headlist = git_get_refs_list("refs/heads");
|
if (@headlist) {
|
||||||
if (defined @$headlist) {
|
|
||||||
git_print_header_div('heads');
|
git_print_header_div('heads');
|
||||||
git_heads_body($headlist, $head, 0, 15,
|
git_heads_body(\@headlist, $head, 0, 15,
|
||||||
$cgi->a({-href => href(action=>"heads")}, "..."));
|
$cgi->a({-href => href(action=>"heads")}, "..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2557,7 +2575,7 @@ sub git_tags {
|
|||||||
git_print_page_nav('','', $head,undef,$head);
|
git_print_page_nav('','', $head,undef,$head);
|
||||||
git_print_header_div('summary', $project);
|
git_print_header_div('summary', $project);
|
||||||
|
|
||||||
my $taglist = git_get_refs_list("refs/tags");
|
my ($taglist) = git_get_refs_list("tags");
|
||||||
if (defined @$taglist) {
|
if (defined @$taglist) {
|
||||||
git_tags_body($taglist);
|
git_tags_body($taglist);
|
||||||
}
|
}
|
||||||
@ -2570,9 +2588,9 @@ sub git_heads {
|
|||||||
git_print_page_nav('','', $head,undef,$head);
|
git_print_page_nav('','', $head,undef,$head);
|
||||||
git_print_header_div('summary', $project);
|
git_print_header_div('summary', $project);
|
||||||
|
|
||||||
my $taglist = git_get_refs_list("refs/heads");
|
my ($headlist) = git_get_refs_list("heads");
|
||||||
if (defined @$taglist) {
|
if (defined @$headlist) {
|
||||||
git_heads_body($taglist, $head);
|
git_heads_body($headlist, $head);
|
||||||
}
|
}
|
||||||
git_footer_html();
|
git_footer_html();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user