summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8e85cdc)
raw | patch | inline | side by side (parent: 8e85cdc)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 1 Aug 2006 02:18:34 +0000 (19:18 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 1 Aug 2006 02:21:38 +0000 (19:21 -0700) |
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>
hardcoded up-to-two-level assumption. Lift it by using
File::Find.
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.cgi | patch | blob | history |
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index 4e79390aff051f6a264a9b5a65a7b9e5c69ce051..9569af09b5dd201a3f646071e6c82c01643d40d5 100755 (executable)
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
use CGI::Carp qw(fatalsToBrowser);
use Encode;
use Fcntl ':mode';
+use File::Find qw();
binmode STDOUT, ':utf8';
our $cgi = new CGI;
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;