aboutsummaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorLuke Lu <git@vicaya.com>2007-10-16 20:45:25 -0700
committerShawn O. Pearce <spearce@spearce.org>2007-10-17 01:23:33 -0400
commitca5e9495607c2abb4b665b75d3d96a457fa4c5dd (patch)
treed46a30f3674c27a19aa87bd2be731f75bf972996 /gitweb
parent317efa63fc457d1a726902ddf97298c201df627c (diff)
downloadgit-ca5e9495607c2abb4b665b75d3d96a457fa4c5dd.tar.gz
git-ca5e9495607c2abb4b665b75d3d96a457fa4c5dd.tar.xz
gitweb: speed up project listing on large work trees by limiting find depth
Signed-off-by: Luke Lu <git@vicaya.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.perl10
1 files changed, 10 insertions, 0 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3064298f2..48e21dad6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -35,6 +35,10 @@ our $GIT = "++GIT_BINDIR++/git";
#our $projectroot = "/pub/scm";
our $projectroot = "++GITWEB_PROJECTROOT++";
+# fs traversing limit for getting project list
+# the number is relative to the projectroot
+our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
+
# target of the home link on top of all pages
our $home_link = $my_uri || "/";
@@ -1509,6 +1513,7 @@ sub git_get_projects_list {
# remove the trailing "/"
$dir =~ s!/+$!!;
my $pfxlen = length("$dir");
+ my $pfxdepth = ($dir =~ tr!/!!);
File::Find::find({
follow_fast => 1, # follow symbolic links
@@ -1519,6 +1524,11 @@ sub git_get_projects_list {
return if (m!^[/.]$!);
# only directories can be git repositories
return unless (-d $_);
+ # don't traverse too deep (Find is super slow on os x)
+ if (($File::Find::name =~ tr!/!!) - $pfxdepth > $project_maxdepth) {
+ $File::Find::prune = 1;
+ return;
+ }
my $subdir = substr($File::Find::name, $pfxlen + 1);
# we check related file in $projectroot