[JGIT PATCH] Add --export-all to jgit daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux