[PATCH] Show non-naked git repositories in subdirectories as well.
- From
Junio C Hamano <junkio@cox.net>
- Date
- Jan 12, 2006, 08:55 UTC
- Message-ID
- <7v8xtlrfkf.fsf@assigned-by-dhcp.cox.net>
This allows $projects_list to name a directory under which a non-naked git project trees can hang.
Signed-off-by: Junio C Hamano <junkio@cox.net>
--- * The development of this patch was done using the experimental "git checkout" I posted in thread:
http://thread.gmane.org/gmane.comp.version-control.git/14375
With the same workflow as I described there, I added this feature by working in the test branch, and then did this:
$ git checkout -b projects master
which automerged the changes in the test branch over to a new branch, based on Kay's upstream (thereby removing the effect of my other changes I had in the test branch). All I had to do after that was to make a commit, and I am reasonably happy to see the checkout change is working nicely.
gitweb.cgi | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
c302bfde91563778155084d13453b1c2bdc771d8
diff --git a/gitweb.cgi b/gitweb.cgi index 986d7da..ed52ed0 100755 --- a/gitweb.cgi +++ b/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(find); binmode STDOUT, ':utf8'; my $cgi = new CGI; @@ -794,17 +795,18 @@ sub git_read_projects { 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, + my $pl = quotemeta($projects_list); + find(sub { + if (/\.git$/ && -d _ && + (-l "$File::Find::name/HEAD" || -f _) && + $File::Find::name =~ /^$pl\/(.*)/) { + push @list, { + path => "$1" }; - push @list, $pr + $File::Find::prune = 1; } - } - closedir($dh); + }, $projects_list); + } elsif (-f $projects_list) { # read from file(url-encoded): # 'git%2Fgit.git Linus+Torvalds'
-- 1.1.1-g8a769