git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH] Add --export-all to jgit daemon
Date: Wed, 11 Feb 2009 14:59:38 -0800	[thread overview]
Message-ID: <1234393178-4429-1-git-send-email-spearce@spearce.org> (raw)

Sometimes its useful to export an entire directory tree,
without needing to create git-daemon-export-ok everywhere.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/pgm/Daemon.java           |    4 ++
 .../src/org/spearce/jgit/transport/Daemon.java     |   37 +++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Daemon.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Daemon.java
index 39b43b2..e064fd8 100644
--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Daemon.java
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Daemon.java
@@ -66,6 +66,9 @@
 	@Option(name = "--forbid-override", metaVar = "SERVICE", usage = "configure the service in daemon.servicename", multiValued = true)
 	final List<String> forbidOverride = new ArrayList<String>();
 
+	@Option(name = "--export-all", usage = "export without git-daemon-export-ok")
+	boolean exportAll;
+
 	@Argument(required = true, metaVar = "DIRECTORY", usage = "directories to export")
 	final List<File> directory = new ArrayList<File>();
 
@@ -81,6 +84,7 @@ protected void run() throws Exception {
 		d = new org.spearce.jgit.transport.Daemon(
 				host != null ? new InetSocketAddress(host, port)
 						: new InetSocketAddress(port));
+		d.setExportAll(exportAll);
 
 		for (final String n : enable)
 			service(d, n).setEnabled(true);
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
index e5b446c..be27732 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
@@ -69,6 +69,8 @@
 
 	private final ThreadGroup processors;
 
+	private boolean exportAll;
+
 	private Map<String, Repository> exports;
 
 	private Collection<File> exportBase;
@@ -155,6 +157,32 @@ public synchronized DaemonService getService(String name) {
 	}
 
 	/**
+	 * @return false if <code>git-daemon-export-ok</code> is required to export
+	 *         a repository; true if <code>git-daemon-export-ok</code> is
+	 *         ignored.
+	 * @see #setExportAll(boolean)
+	 */
+	public synchronized boolean isExportAll() {
+		return exportAll;
+	}
+
+	/**
+	 * Set whether or not to export all repositories.
+	 * <p>
+	 * If false (the default), repositories must have a
+	 * <code>git-daemon-export-ok</code> file to be accessed through this
+	 * daemon.
+	 * <p>
+	 * If true, all repositories are available through the daemon, whether or
+	 * not <code>git-daemon-export-ok</code> exists.
+	 *
+	 * @param export
+	 */
+	public synchronized void setExportAll(final boolean export) {
+		exportAll = export;
+	}
+
+	/**
 	 * Add a single repository to the set that is exported by this daemon.
 	 * <p>
 	 * The existence (or lack-thereof) of <code>git-daemon-export-ok</code> is
@@ -336,7 +364,7 @@ synchronized (exportBase) {
 	}
 
 	private Repository openRepository(final File d) {
-		if (d.isDirectory() && new File(d, "git-daemon-export-ok").exists()) {
+		if (d.isDirectory() && canExport(d)) {
 			try {
 				return new Repository(d);
 			} catch (IOException err) {
@@ -345,4 +373,11 @@ private Repository openRepository(final File d) {
 		}
 		return null;
 	}
+
+	private boolean canExport(final File d) {
+		if (isExportAll()) {
+			return true;
+		}
+		return new File(d, "git-daemon-export-ok").exists();
+	}
 }
-- 
1.6.2.rc0.204.gf6b427

                 reply	other threads:[~2009-02-11 23:01 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=1234393178-4429-1-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    /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;
as well as URLs for NNTP newsgroup(s).