{"thread":{"id":"3057","subject":"[PATCH] Show non-naked git repositories in subdirectories as well.","startedAt":"2006-01-12T08:55:12Z","lastAt":"2006-01-12T08:55:12Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"14540","messageId":"7v8xtlrfkf.fsf@assigned-by-dhcp.cox.net","threadId":"3057","inReplyTo":null,"subject":"[PATCH] Show non-naked git repositories in subdirectories as well.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-01-12T08:55:12Z","receivedAt":"2006-01-12T08:55:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This allows $projects_list to name a directory under which a\nnon-naked git project trees can hang.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n * The development of this patch was done using the experimental\n   \"git checkout\" I posted in thread:\n\n     http://thread.gmane.org/gmane.comp.version-control.git/14375\n\n   With the same workflow as I described there, I added this\n   feature by working in the test branch, and then did this:\n\n     $ git checkout -b projects master\n\n   which automerged the changes in the test branch over to a new\n   branch, based on Kay's upstream (thereby removing the effect\n   of my other changes I had in the test branch).  All I had to\n   do after that was to make a commit, and I am reasonably happy\n   to see the checkout change is working nicely.\n\n gitweb.cgi |   20 +++++++++++---------\n 1 files changed, 11 insertions(+), 9 deletions(-)\n\nc302bfde91563778155084d13453b1c2bdc771d8\ndiff --git a/gitweb.cgi b/gitweb.cgi\nindex 986d7da..ed52ed0 100755\n--- a/gitweb.cgi\n+++ b/gitweb.cgi\n@@ -14,6 +14,7 @@ use CGI::Util qw(unescape);\n use CGI::Carp qw(fatalsToBrowser);\n use Encode;\n use Fcntl ':mode';\n+use File::Find qw(find);\n binmode STDOUT, ':utf8';\n \n my $cgi = new CGI;\n@@ -794,17 +795,18 @@ sub git_read_projects {\n \n \tif (-d $projects_list) {\n \t\t# search in directory\n-\t\tmy $dir = $projects_list;\n-\t\topendir my $dh, $dir or return undef;\n-\t\twhile (my $dir = readdir($dh)) {\n-\t\t\tif (-e \"$projectroot/$dir/HEAD\") {\n-\t\t\t\tmy $pr = {\n-\t\t\t\t\tpath => $dir,\n+\t\tmy $pl = quotemeta($projects_list);\n+\t\tfind(sub {\n+\t\t\tif (/\\.git$/ && -d _ &&\n+\t\t\t    (-l \"$File::Find::name/HEAD\" || -f _) &&\n+\t\t\t    $File::Find::name =~ /^$pl\\/(.*)/) {\n+\t\t\t\tpush @list, {\n+\t\t\t\t\tpath => \"$1\"\n \t\t\t\t};\n-\t\t\t\tpush @list, $pr\n+\t\t\t\t$File::Find::prune = 1;\n \t\t\t}\n-\t\t}\n-\t\tclosedir($dh);\n+\t\t}, $projects_list);\n+\n \t} elsif (-f $projects_list) {\n \t\t# read from file(url-encoded):\n \t\t# 'git%2Fgit.git Linus+Torvalds'\n-- \n1.1.1-g8a769\n"}]}