{"thread":{"id":"17732","subject":"[JGIT PATCH] Add --export-all to jgit daemon","startedAt":"2009-02-11T22:59:38Z","lastAt":"2009-02-11T22:59:38Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"104311","messageId":"1234393178-4429-1-git-send-email-spearce@spearce.org","threadId":"17732","inReplyTo":null,"subject":"[JGIT PATCH] Add --export-all to jgit daemon","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-02-11T22:59:38Z","receivedAt":"2009-02-11T22:59:38Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Sometimes its useful to export an entire directory tree,\nwithout needing to create git-daemon-export-ok everywhere.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .../src/org/spearce/jgit/pgm/Daemon.java           |    4 ++\n .../src/org/spearce/jgit/transport/Daemon.java     |   37 +++++++++++++++++++-\n 2 files changed, 40 insertions(+), 1 deletions(-)\n\ndiff --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\nindex 39b43b2..e064fd8 100644\n--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Daemon.java\n+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Daemon.java\n@@ -66,6 +66,9 @@\n \t@Option(name = \"--forbid-override\", metaVar = \"SERVICE\", usage = \"configure the service in daemon.servicename\", multiValued = true)\n \tfinal List<String> forbidOverride = new ArrayList<String>();\n \n+\t@Option(name = \"--export-all\", usage = \"export without git-daemon-export-ok\")\n+\tboolean exportAll;\n+\n \t@Argument(required = true, metaVar = \"DIRECTORY\", usage = \"directories to export\")\n \tfinal List<File> directory = new ArrayList<File>();\n \n@@ -81,6 +84,7 @@ protected void run() throws Exception {\n \t\td = new org.spearce.jgit.transport.Daemon(\n \t\t\t\thost != null ? new InetSocketAddress(host, port)\n \t\t\t\t\t\t: new InetSocketAddress(port));\n+\t\td.setExportAll(exportAll);\n \n \t\tfor (final String n : enable)\n \t\t\tservice(d, n).setEnabled(true);\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java\nindex e5b446c..be27732 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java\n@@ -69,6 +69,8 @@\n \n \tprivate final ThreadGroup processors;\n \n+\tprivate boolean exportAll;\n+\n \tprivate Map<String, Repository> exports;\n \n \tprivate Collection<File> exportBase;\n@@ -155,6 +157,32 @@ public synchronized DaemonService getService(String name) {\n \t}\n \n \t/**\n+\t * @return false if <code>git-daemon-export-ok</code> is required to export\n+\t *         a repository; true if <code>git-daemon-export-ok</code> is\n+\t *         ignored.\n+\t * @see #setExportAll(boolean)\n+\t */\n+\tpublic synchronized boolean isExportAll() {\n+\t\treturn exportAll;\n+\t}\n+\n+\t/**\n+\t * Set whether or not to export all repositories.\n+\t * <p>\n+\t * If false (the default), repositories must have a\n+\t * <code>git-daemon-export-ok</code> file to be accessed through this\n+\t * daemon.\n+\t * <p>\n+\t * If true, all repositories are available through the daemon, whether or\n+\t * not <code>git-daemon-export-ok</code> exists.\n+\t *\n+\t * @param export\n+\t */\n+\tpublic synchronized void setExportAll(final boolean export) {\n+\t\texportAll = export;\n+\t}\n+\n+\t/**\n \t * Add a single repository to the set that is exported by this daemon.\n \t * <p>\n \t * The existence (or lack-thereof) of <code>git-daemon-export-ok</code> is\n@@ -336,7 +364,7 @@ synchronized (exportBase) {\n \t}\n \n \tprivate Repository openRepository(final File d) {\n-\t\tif (d.isDirectory() && new File(d, \"git-daemon-export-ok\").exists()) {\n+\t\tif (d.isDirectory() && canExport(d)) {\n \t\t\ttry {\n \t\t\t\treturn new Repository(d);\n \t\t\t} catch (IOException err) {\n@@ -345,4 +373,11 @@ private Repository openRepository(final File d) {\n \t\t}\n \t\treturn null;\n \t}\n+\n+\tprivate boolean canExport(final File d) {\n+\t\tif (isExportAll()) {\n+\t\t\treturn true;\n+\t\t}\n+\t\treturn new File(d, \"git-daemon-export-ok\").exists();\n+\t}\n }\n-- \n1.6.2.rc0.204.gf6b427\n"}]}