gitweb: There can be more than two levels of subdirectories
Earlier code to read .git/refs/{tags,heads} hierarchy had a hardcoded up-to-two-level assumption. Lift it by using File::Find. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
@ -14,6 +14,7 @@ use CGI::Util qw(unescape);
|
|||||||
use CGI::Carp qw(fatalsToBrowser);
|
use CGI::Carp qw(fatalsToBrowser);
|
||||||
use Encode;
|
use Encode;
|
||||||
use Fcntl ':mode';
|
use Fcntl ':mode';
|
||||||
|
use File::Find qw();
|
||||||
binmode STDOUT, ':utf8';
|
binmode STDOUT, ':utf8';
|
||||||
|
|
||||||
our $cgi = new CGI;
|
our $cgi = new CGI;
|
||||||
@ -697,23 +698,14 @@ sub git_read_refs {
|
|||||||
my @reflist;
|
my @reflist;
|
||||||
|
|
||||||
my @refs;
|
my @refs;
|
||||||
opendir my $dh, "$projectroot/$project/$ref_dir";
|
my $pfxlen = length("$projectroot/$project/$ref_dir");
|
||||||
while (my $dir = readdir($dh)) {
|
File::Find::find(sub {
|
||||||
if ($dir =~ m/^\./) {
|
return if (/^\./);
|
||||||
next;
|
if (-f $_) {
|
||||||
|
push @refs, substr($File::Find::name, $pfxlen + 1);
|
||||||
}
|
}
|
||||||
if (-d "$projectroot/$project/$ref_dir/$dir") {
|
}, "$projectroot/$project/$ref_dir");
|
||||||
opendir my $dh2, "$projectroot/$project/$ref_dir/$dir";
|
|
||||||
my @subdirs = grep !m/^\./, readdir $dh2;
|
|
||||||
closedir($dh2);
|
|
||||||
foreach my $subdir (@subdirs) {
|
|
||||||
push @refs, "$dir/$subdir"
|
|
||||||
}
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
push @refs, $dir;
|
|
||||||
}
|
|
||||||
closedir($dh);
|
|
||||||
foreach my $ref_file (@refs) {
|
foreach my $ref_file (@refs) {
|
||||||
my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
|
my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
|
||||||
my $type = git_get_type($ref_id) || next;
|
my $type = git_get_type($ref_id) || next;
|
||||||
|
Reference in New Issue
Block a user