git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: export-ok option
@ 2006-09-16 19:27 Matthias Lederhofer
  2006-09-16 19:40 ` Jakub Narebski
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Matthias Lederhofer @ 2006-09-16 19:27 UTC (permalink / raw)
  To: git

Similar to git-daemon checking for git-daemon-export-ok this
introduces an optional check before showing a repository in gitweb.

I also changed the 'No such directory' error message to 'No such
project' because the user visiting my gitweb should not know what
directories I have in the project root directory.

undef $project; is used to prevent displaying the description.
---
Perhaps there should be another option which allows only those
repositories to be shown which are in $projects_list.
---
 Makefile           |    2 ++
 gitweb/gitweb.perl |   18 ++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 7b3114f..63df24c 100644
--- a/Makefile
+++ b/Makefile
@@ -132,6 +132,7 @@ GITWEB_HOMETEXT = indextext.html
 GITWEB_CSS = gitweb.css
 GITWEB_LOGO = git-logo.png
 GITWEB_FAVICON = git-favicon.png
+GITWEB_EXPORT_OK =
 
 export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
 
@@ -637,6 +638,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \
 	    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 	    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
+	    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
 	    $< >$@+
 	chmod +x $@+
 	mv $@+ $@
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d89f709..3944d13 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -54,6 +54,9 @@ our $favicon = "++GITWEB_FAVICON++";
 # source of projects list
 our $projects_list = "++GITWEB_LIST++";
 
+# show repository only if this file exists
+our $export_ok = "++GITWEB_EXPORT_OK++";
+
 # list of git base URLs used for URL to where fetch project from,
 # i.e. full URL is "$git_base_url/$project"
 our @git_base_url_list = ("++GITWEB_BASE_URL++");
@@ -181,12 +184,13 @@ if (defined $project) {
 }
 if (defined $project) {
 	if (!validate_input($project)) {
+		undef $project;
 		die_error(undef, "Invalid project parameter");
 	}
-	if (!(-d "$projectroot/$project")) {
-		die_error(undef, "No such directory");
-	}
-	if (!(-e "$projectroot/$project/HEAD")) {
+	if (!(-d "$projectroot/$project") ||
+	    !(-e "$projectroot/$project/HEAD") ||
+	    ($export_ok && !(-e "$projectroot/$project/$export_ok"))) {
+		undef $project;
 		die_error(undef, "No such project");
 	}
 	$git_dir = "$projectroot/$project";
@@ -694,7 +698,8 @@ sub git_get_projects_list {
 		my $dir = $projects_list;
 		opendir my ($dh), $dir or return undef;
 		while (my $dir = readdir($dh)) {
-			if (-e "$projectroot/$dir/HEAD") {
+			if (-e "$projectroot/$dir/HEAD" && (!$export_ok ||
+			    -e "$projectroot/$dir/$export_ok")) {
 				my $pr = {
 					path => $dir,
 				};
@@ -716,7 +721,8 @@ sub git_get_projects_list {
 			if (!defined $path) {
 				next;
 			}
-			if (-e "$projectroot/$path/HEAD") {
+			if (-e "$projectroot/$path/HEAD" && (!$export_ok ||
+			    -e "$projectroot/$path/$export_ok")) {
 				my $pr = {
 					path => $path,
 					owner => decode("utf8", $owner, Encode::FB_DEFAULT),
-- 
1.4.2.g0ea2

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-09-17 23:10 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-16 19:27 [PATCH] gitweb: export-ok option Matthias Lederhofer
2006-09-16 19:40 ` Jakub Narebski
2006-09-16 20:33   ` Matthias Lederhofer
2006-09-16 20:37   ` Junio C Hamano
2006-09-16 19:44 ` Jakub Narebski
2006-09-16 21:43 ` [PATCH] gitweb: option 'strict export' Matthias Lederhofer
2006-09-16 22:30 ` [PATCH/current master] gitweb: do not use 'No such directory' error message Matthias Lederhofer
2006-09-16 22:31   ` [PATCH] gitweb: export options Matthias Lederhofer
2006-09-17  8:53     ` Junio C Hamano
2006-09-17  9:07       ` Matthias Lederhofer
2006-09-17 10:34         ` Junio C Hamano
2006-09-17 13:29           ` [PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export Matthias Lederhofer
2006-09-17 22:06             ` Junio C Hamano
2006-09-17 22:45               ` Jakub Narebski
2006-09-17 23:10                 ` 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;
as well as URLs for NNTP newsgroup(s).