diff options
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java | 1 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java | 37 |
2 files changed, 37 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java index bae895cc76..14dcb1f50d 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CLIText.java @@ -67,6 +67,7 @@ public class CLIText extends TranslationBundle { /***/ public String branchIsNotAnAncestorOfYourCurrentHEAD; /***/ public String branchNotFound; /***/ public String cacheTreePathInfo; + /***/ public String configFileNotFound; /***/ public String cannotBeRenamed; /***/ public String cannotChekoutNoHeadsAdvertisedByRemote; /***/ public String cannotCreateCommand; diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java index f015a9e7bd..3cca87abe8 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java @@ -48,13 +48,22 @@ import java.net.InetSocketAddress; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.Executors; +import org.eclipse.jgit.storage.file.FileBasedConfig; +import org.eclipse.jgit.storage.file.WindowCache; +import org.eclipse.jgit.storage.file.WindowCacheConfig; +import org.eclipse.jgit.storage.pack.PackConfig; +import org.eclipse.jgit.transport.DaemonService; +import org.eclipse.jgit.util.FS; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; -import org.eclipse.jgit.transport.DaemonService; @Command(common = true, usage = "usage_exportRepositoriesOverGit") class Daemon extends TextBuiltin { + @Option(name = "--config-file", metaVar = "metaVar_configFile", usage = "usage_configFile") + File configFile; + @Option(name = "--port", metaVar = "metaVar_port", usage = "usage_portNumberToListenOn") int port = org.eclipse.jgit.transport.Daemon.DEFAULT_PORT; @@ -89,12 +98,38 @@ class Daemon extends TextBuiltin { @Override protected void run() throws Exception { + PackConfig packConfig = new PackConfig(); + + if (configFile != null) { + if (!configFile.exists()) { + throw die(MessageFormat.format( + CLIText.get().configFileNotFound, // + configFile.getAbsolutePath())); + } + + FileBasedConfig cfg = new FileBasedConfig(configFile, FS.DETECTED); + cfg.load(); + + WindowCacheConfig wcc = new WindowCacheConfig(); + wcc.fromConfig(cfg); + WindowCache.reconfigure(wcc); + + packConfig.fromConfig(cfg); + } + + int threads = packConfig.getThreads(); + if (threads <= 0) + threads = Runtime.getRuntime().availableProcessors(); + if (1 < threads) + packConfig.setExecutor(Executors.newFixedThreadPool(threads)); + final org.eclipse.jgit.transport.Daemon d; d = new org.eclipse.jgit.transport.Daemon( host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(port)); d.setExportAll(exportAll); + d.setPackConfig(packConfig); if (0 <= timeout) d.setTimeout(timeout); |