summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-01 02:18:34 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-08-01 02:21:38 (GMT)
commit7a13b999a5aa6de236c7b16139c765eb9e5cb3c4 (patch)
treec795d4bf63a958c7e13e36414df0a6340293688f /gitweb
parent8e85cdc4efd15fa70dfbbfebaf3ef9a758c2772c (diff)
downloadgit-7a13b999a5aa6de236c7b16139c765eb9e5cb3c4.zip
git-7a13b999a5aa6de236c7b16139c765eb9e5cb3c4.tar.gz
git-7a13b999a5aa6de236c7b16139c765eb9e5cb3c4.tar.bz2
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>
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.cgi24
1 files changed, 8 insertions, 16 deletions
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 4e79390..9569af0 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -14,6 +14,7 @@ use CGI::Util qw(unescape);
use CGI::Carp qw(fatalsToBrowser);
use Encode;
use Fcntl ':mode';
+use File::Find qw();
binmode STDOUT, ':utf8';
our $cgi = new CGI;
@@ -697,23 +698,14 @@ sub git_read_refs {
my @reflist;
my @refs;
- opendir my $dh, "$projectroot/$project/$ref_dir";
- while (my $dir = readdir($dh)) {
- if ($dir =~ m/^\./) {
- next;
- }
- if (-d "$projectroot/$project/$ref_dir/$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;
+ my $pfxlen = length("$projectroot/$project/$ref_dir");
+ File::Find::find(sub {
+ return if (/^\./);
+ if (-f $_) {
+ push @refs, substr($File::Find::name, $pfxlen + 1);
}
- push @refs, $dir;
- }
- closedir($dh);
+ }, "$projectroot/$project/$ref_dir");
+
foreach my $ref_file (@refs) {
my $ref_id = git_read_hash("$project/$ref_dir/$ref_file");
my $type = git_get_type($ref_id) || next;