File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ GITWEB_CONFIG = gitweb_config.perl
165
165
GITWEB_HOME_LINK_STR = projects
166
166
GITWEB_SITENAME =
167
167
GITWEB_PROJECTROOT = /pub/git
168
+ GITWEB_PROJECT_MAXDEPTH = 2007
168
169
GITWEB_EXPORT_OK =
169
170
GITWEB_STRICT_EXPORT =
170
171
GITWEB_BASE_URL =
@@ -831,6 +832,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
831
832
-e ' s|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
832
833
-e ' s|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
833
834
-e ' s|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
835
+ -e ' s|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
834
836
-e ' s|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
835
837
-e ' s|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
836
838
-e ' s|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
Original file line number Diff line number Diff line change 35
35
# our $projectroot = "/pub/scm";
36
36
our $projectroot = " ++GITWEB_PROJECTROOT++" ;
37
37
38
+ # fs traversing limit for getting project list
39
+ # the number is relative to the projectroot
40
+ our $project_maxdepth = " ++GITWEB_PROJECT_MAXDEPTH++" ;
41
+
38
42
# target of the home link on top of all pages
39
43
our $home_link = $my_uri || " /" ;
40
44
@@ -1509,6 +1513,7 @@ sub git_get_projects_list {
1509
1513
# remove the trailing "/"
1510
1514
$dir =~ s ! /+$!! ;
1511
1515
my $pfxlen = length (" $dir " );
1516
+ my $pfxdepth = ($dir =~ tr ! /!! );
1512
1517
1513
1518
File::Find::find({
1514
1519
follow_fast => 1, # follow symbolic links
@@ -1519,6 +1524,11 @@ sub git_get_projects_list {
1519
1524
return if (m ! ^[/.] $ ! );
1520
1525
# only directories can be git repositories
1521
1526
return unless (-d $_ );
1527
+ # don't traverse too deep (Find is super slow on os x)
1528
+ if (($File::Find::name =~ tr ! /!! ) - $pfxdepth > $project_maxdepth ) {
1529
+ $File::Find::prune = 1;
1530
+ return ;
1531
+ }
1522
1532
1523
1533
my $subdir = substr ($File::Find::name , $pfxlen + 1);
1524
1534
# we check related file in $projectroot
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ gitweb_init () {
18
18
our \$ version = "current";
19
19
our \$ GIT = "git";
20
20
our \$ projectroot = "$( pwd) ";
21
+ our \$ project_maxdepth = 8;
21
22
our \$ home_link_str = "projects";
22
23
our \$ site_name = "[localhost]";
23
24
our \$ site_header = "";
You can’t perform that action at this time.
0 commit comments