From bd196e554bb6f5cb97cd02bc7a90c6924ff9b858 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Tue, 10 Jul 2012 17:41:24 -0400
Subject: [PATCH] Updated Apache Commons Daemon to 1.0.10

---
 src/com/gitblit/GitBlit.java |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 57421a3..eab265a 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -30,6 +30,7 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
@@ -55,6 +56,8 @@
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.lib.RepositoryCache.FileKey;
 import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.storage.file.WindowCache;
+import org.eclipse.jgit.storage.file.WindowCacheConfig;
 import org.eclipse.jgit.transport.resolver.FileResolver;
 import org.eclipse.jgit.transport.resolver.RepositoryResolver;
 import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
@@ -186,6 +189,15 @@
 		return self().timezone;
 	}
 	
+	/**
+	 * Returns the user-defined blob encodings.
+	 * 
+	 * @return an array of encodings, may be empty
+	 */
+	public static String [] getEncodings() {
+		return getStrings(Keys.web.blobEncodings).toArray(new String[0]);
+	}
+	
 
 	/**
 	 * Returns the boolean value for the specified key. If the key does not
@@ -252,6 +264,17 @@
 	 */
 	public static List<String> getStrings(String key) {
 		return self().settings.getStrings(key);
+	}
+
+	/**
+	 * Returns a map of space-separated key-value pairs from the specified key.
+	 * 
+	 * @see IStoredSettings.getStrings(String key)
+	 * @param name
+	 * @return map of string, string
+	 */
+	public static Map<String, String> getMap(String key) {
+		return self().settings.getMap(key);
 	}
 
 	/**
@@ -837,7 +860,7 @@
 			model.useTickets = getConfig(config, "useTickets", false);
 			model.useDocs = getConfig(config, "useDocs", false);
 			model.accessRestriction = AccessRestrictionType.fromName(getConfig(config,
-					"accessRestriction", null));
+					"accessRestriction", settings.getString(Keys.git.defaultAccessRestriction, null)));
 			model.showRemoteBranches = getConfig(config, "showRemoteBranches", false);
 			model.isFrozen = getConfig(config, "isFrozen", false);
 			model.showReadme = getConfig(config, "showReadme", false);
@@ -859,7 +882,7 @@
 					Constants.CONFIG_GITBLIT, null, "indexBranch")));
 			
 			// Custom defined properties
-			model.customFields = new HashMap<String, String>();
+			model.customFields = new LinkedHashMap<String, String>();
 			for (String aProperty : config.getNames(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS)) {
 				model.customFields.put(aProperty, config.getString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, aProperty));
 			}
@@ -1800,9 +1823,13 @@
 		// ensure that the current values are updated in the setting models
 		for (String key : settings.getAllKeys(null)) {
 			SettingModel setting = settingsModel.get(key);
-			if (setting != null) {
-				setting.currentValue = settings.getString(key, "");
+			if (setting == null) {
+				// unreferenced setting, create a setting model
+				setting = new SettingModel();
+				setting.name = key;
+				settingsModel.add(setting);
 			}
+			setting.currentValue = settings.getString(key, "");			
 		}
 		settingsModel.pushScripts = getAllScripts();
 		return settingsModel;
@@ -1917,7 +1944,29 @@
 		scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
 		if (startFederation) {
 			configureFederation();
-		}		
+		}
+		
+		// Configure JGit
+		WindowCacheConfig cfg = new WindowCacheConfig();
+		
+		cfg.setPackedGitWindowSize(settings.getFilesize(Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
+		cfg.setPackedGitLimit(settings.getFilesize(Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
+		cfg.setDeltaBaseCacheLimit(settings.getFilesize(Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
+		cfg.setPackedGitOpenFiles(settings.getFilesize(Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles()));
+		cfg.setStreamFileThreshold(settings.getFilesize(Keys.git.streamFileThreshold, cfg.getStreamFileThreshold()));
+		cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
+		
+		try {
+			WindowCache.reconfigure(cfg);
+			logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
+			logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
+			logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
+			logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles()));
+			logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.streamFileThreshold, cfg.getStreamFileThreshold()));
+			logger.debug(MessageFormat.format("{0} = {1}", Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
+		} catch (IllegalArgumentException e) {
+			logger.error("Failed to configure JGit parameters!", e);
+		}
 	}
 	
 	private void logTimezone(String type, TimeZone zone) {

--
Gitblit v1.9.1