git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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
Message 1 of 1 in “Show non-naked git repositories in subdirectories as well.”
  1. Show non-naked git repositories in subdirectories as well.Junio C Hamano, Jan 12, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.