diff options
author | Jakub Narebski <jnareb@gmail.com> | 2006-09-14 22:18:59 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-09-14 22:38:19 -0700 |
commit | c0011ff8c83f200139267492589575970fb72afc (patch) | |
tree | 1bb48ae3cbe45b326dea77cc41237bbdfff3e7c7 /gitweb | |
parent | 5b6df8e45f31c7eb26c30536448cffe1b715e1ce (diff) | |
download | git-c0011ff8c83f200139267492589575970fb72afc.tar.gz git-c0011ff8c83f200139267492589575970fb72afc.tar.xz |
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>
Diffstat (limited to 'gitweb')
-rwxr-xr-x | gitweb/gitweb.perl | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index c3544ddc4..1d3a4c1e5 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -715,16 +715,26 @@ sub git_get_projects_list { if (-d $projects_list) { # search in directory my $dir = $projects_list; - opendir my ($dh), $dir or return undef; - while (my $dir = readdir($dh)) { - if (-e "$projectroot/$dir/HEAD") { - my $pr = { - path => $dir, - }; - push @list, $pr - } - } - closedir($dh); + my $pfxlen = length("$dir"); + + File::Find::find({ + follow_fast => 1, # follow symbolic links + dangling_symlinks => 0, # ignore dangling symlinks, silently + wanted => sub { + # skip project-list toplevel, if we get it. + return if (m!^[/.]$!); + # only directories can be git repositories + 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) { # read from file(url-encoded): # 'git%2Fgit.git Linus+Torvalds' |