* [PATCH] Show non-naked git repositories in subdirectories as well.
@ 2006-01-12 8:55 Junio C Hamano
0 siblings, 0 replies; only message in thread
From: Junio C Hamano @ 2006-01-12 8:55 UTC (permalink / raw)
To: Kay Sievers; +Cc: git
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2006-01-12 8:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-12 8:55 [PATCH] Show non-naked git repositories in subdirectories as well Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox