Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Kay Sievers <kay.sievers@suse.de>
Cc: git@vger.kernel.org
Subject: [PATCH] Show non-naked git repositories in subdirectories as well.
Date: Thu, 12 Jan 2006 00:55:12 -0800	[thread overview]
Message-ID: <7v8xtlrfkf.fsf@assigned-by-dhcp.cox.net> (raw)

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

                 reply	other threads:[~2006-01-12  8:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v8xtlrfkf.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=kay.sievers@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox