mirror of
https://github.com/git/git.git
synced 2025-03-30 19:10:25 +00:00
gitweb: Use File::Find::find in git_get_projects_list
Earlier code to get list of projects when $projects_list is a directory (e.g. when it is equal to $projectroot) had a hardcoded flat (one level) list of directories. Allow for projects to be in subdirectories also for $projects_list being a directory by using File::Find. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
5b6df8e45f
commit
c0011ff8c8
@ -715,16 +715,26 @@ sub git_get_projects_list {
|
|||||||
if (-d $projects_list) {
|
if (-d $projects_list) {
|
||||||
# search in directory
|
# search in directory
|
||||||
my $dir = $projects_list;
|
my $dir = $projects_list;
|
||||||
opendir my ($dh), $dir or return undef;
|
my $pfxlen = length("$dir");
|
||||||
while (my $dir = readdir($dh)) {
|
|
||||||
if (-e "$projectroot/$dir/HEAD") {
|
File::Find::find({
|
||||||
my $pr = {
|
follow_fast => 1, # follow symbolic links
|
||||||
path => $dir,
|
dangling_symlinks => 0, # ignore dangling symlinks, silently
|
||||||
};
|
wanted => sub {
|
||||||
push @list, $pr
|
# skip project-list toplevel, if we get it.
|
||||||
}
|
return if (m!^[/.]$!);
|
||||||
}
|
# only directories can be git repositories
|
||||||
closedir($dh);
|
return unless (-d $_);
|
||||||
|
|
||||||
|
my $subdir = substr($File::Find::name, $pfxlen + 1);
|
||||||
|
# we check related file in $projectroot
|
||||||
|
if (-e "$projectroot/$subdir/HEAD") {
|
||||||
|
push @list, { path => $subdir };
|
||||||
|
$File::Find::prune = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, "$dir");
|
||||||
|
|
||||||
} elsif (-f $projects_list) {
|
} elsif (-f $projects_list) {
|
||||||
# read from file(url-encoded):
|
# read from file(url-encoded):
|
||||||
# 'git%2Fgit.git Linus+Torvalds'
|
# 'git%2Fgit.git Linus+Torvalds'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user