From 367505e9d8ae0f83edff1dc2392c4af1f518b4d5 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sat, 24 Dec 2011 10:25:23 -0500
Subject: [PATCH] Preliminary update to JGit 1.2.0. This will be refined.

---
 .classpath                       |   20 +++++-----
 docs/04_releases.mkd             |    1 
 src/com/gitblit/GitServlet.java  |   60 ++++++++++++++++++++++-------
 src/com/gitblit/build/Build.java |   16 ++++----
 src/com/gitblit/Constants.java   |    2 
 5 files changed, 65 insertions(+), 34 deletions(-)

diff --git a/.classpath b/.classpath
index e6b336c..d503ab2 100644
--- a/.classpath
+++ b/.classpath
@@ -66,16 +66,6 @@
 			<attribute name="javadoc_location" value="jar:platform:/resource/gitblit/ext/googlecharts-1.4.17-javadoc.jar!/"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="lib" path="ext/org.eclipse.jgit-1.1.0.201109151100-r.jar" sourcepath="ext/org.eclipse.jgit-1.1.0.201109151100-r-sources.jar">
-		<attributes>
-			<attribute name="javadoc_location" value="jar:platform:/resource/gitblit/ext/org.eclipse.jgit-1.1.0.201109151100-r-javadoc.jar!/"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="ext/org.eclipse.jgit.http.server-1.1.0.201109151100-r.jar" sourcepath="ext/org.eclipse.jgit.http.server-1.1.0.201109151100-r-sources.jar">
-		<attributes>
-			<attribute name="javadoc_location" value="jar:platform:/resource/gitblit/ext/org.eclipse.jgit-1.1.0.201109151100-r-javadoc.jar!/"/>
-		</attributes>
-	</classpathentry>
 	<classpathentry kind="lib" path="ext/javax.servlet-3.0.1.jar" sourcepath="ext/javax.servlet-3.0.1-sources.jar"/>
 	<classpathentry kind="lib" path="ext/markdownpapers-core-1.2.5.jar" sourcepath="ext/markdownpapers-core-1.2.5-sources.jar">
 		<attributes>
@@ -102,5 +92,15 @@
 			<attribute name="javadoc_location" value="jar:platform:/resource/gitblit/ext/groovy-all-1.8.4-javadoc.jar!/"/>
 		</attributes>
 	</classpathentry>
+	<classpathentry kind="lib" path="ext/org.eclipse.jgit-1.2.0.201112221803-r.jar" sourcepath="ext/org.eclipse.jgit-1.1.0.201109151100-r-sources.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="jar:platform:/resource/gitblit/ext/org.eclipse.jgit-1.2.0.201112221803-r-javadoc.jar!/"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="lib" path="ext/org.eclipse.jgit.http.server-1.2.0.201112221803-r.jar" sourcepath="ext/org.eclipse.jgit.http.server-1.2.0.201112221803-r-sources.jar">
+		<attributes>
+			<attribute name="javadoc_location" value="jar:platform:/resource/gitblit/ext/org.eclipse.jgit.http.server-1.2.0.201112221803-r-javadoc.jar!/"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index 0ce8621..ae2821d 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -34,6 +34,7 @@
    **New:** *web.allowFlashCopyToClipboard = true*
 - improved: empty repositories now link to a new *empty repository* page which gives some direction to the user for the next step in using Gitblit.  This page displays the primary push/clone url of the repository and gives sample syntax for the git command-line client. (issue 31)
 - improved: unit testing framework has been migrated to JUnit4 syntax and the test suite has been redesigned to run all unit tests, including rpc, federation, and git push/clone tests
+- updated: JGit 1.2.0
 
 ### Older Releases
 
diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java
index c2d5eb2..8171d66 100644
--- a/src/com/gitblit/Constants.java
+++ b/src/com/gitblit/Constants.java
@@ -37,7 +37,7 @@
 
 	// The build script extracts this exact line so be careful editing it
 	// and only use A-Z a-z 0-9 .-_ in the string.
-	public static final String JGIT_VERSION = "JGit 1.1.0 (201109151100-r)";
+	public static final String JGIT_VERSION = "JGit 1.2.0 (201112221803-r)";
 
 	public static final String ADMIN_ROLE = "#admin";
 
diff --git a/src/com/gitblit/GitServlet.java b/src/com/gitblit/GitServlet.java
index 23fb32a..36e1c3e 100644
--- a/src/com/gitblit/GitServlet.java
+++ b/src/com/gitblit/GitServlet.java
@@ -26,10 +26,12 @@
 import java.io.OutputStreamWriter;
 import java.text.MessageFormat;
 import java.util.Collection;
+import java.util.Enumeration;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 
@@ -71,22 +73,9 @@
 
 	private File groovyDir;
 
-	/**
-	 * Configure the servlet from Gitblit's configuration.
-	 */
-	@Override
-	public String getInitParameter(String name) {
-		if (name.equals("base-path")) {
-			return GitBlit.getRepositoriesFolder().getAbsolutePath();
-		} else if (name.equals("export-all")) {
-			return "1";
-		}
-		return super.getInitParameter(name);
-	}
-
 	@Override
 	public void init(ServletConfig config) throws ServletException {
-		groovyDir = GitBlit.getGroovyScriptsFolder();		
+		groovyDir = GitBlit.getGroovyScriptsFolder();
 		try {
 			gse = new GroovyScriptEngine(groovyDir.getAbsolutePath());
 		} catch (IOException e) {
@@ -106,7 +95,48 @@
 				return rp;
 			}
 		});
-		super.init(config);
+		super.init(new GitblitServletConfig(config));
+	}
+
+	/**
+	 * Transitional wrapper class to configure the JGit 1.2 GitFilter.
+	 * This GitServlet will probably be replaced by a GitFilter so that Gitblit
+	 * can serve Git repositories on the root URL and not a /git sub-url.
+	 * 
+	 * @author James Moger
+	 * 
+	 */
+	private class GitblitServletConfig implements ServletConfig {
+		final ServletConfig config;
+
+		GitblitServletConfig(ServletConfig config) {
+			this.config = config;
+		}
+
+		@Override
+		public String getServletName() {
+			return config.getServletName();
+		}
+
+		@Override
+		public ServletContext getServletContext() {
+			return config.getServletContext();
+		}
+
+		@Override
+		public String getInitParameter(String name) {
+			if (name.equals("base-path")) {
+				return GitBlit.getRepositoriesFolder().getAbsolutePath();
+			} else if (name.equals("export-all")) {
+				return "1";
+			}
+			return config.getInitParameter(name);
+		}
+
+		@Override
+		public Enumeration<String> getInitParameterNames() {
+			return config.getInitParameterNames();
+		}
 	}
 
 	/**
diff --git a/src/com/gitblit/build/Build.java b/src/com/gitblit/build/Build.java
index 8ca52c3..1f8554c 100644
--- a/src/com/gitblit/build/Build.java
+++ b/src/com/gitblit/build/Build.java
@@ -457,16 +457,16 @@
 				"3b7c5f3938f202311bdca0bf7ed46bc0118af081");
 
 		public static final MavenObject JGIT = new MavenObject("JGit", "org/eclipse/jgit",
-				"org.eclipse.jgit", "1.1.0.201109151100-r", 1318000, 1354000, 3300000,
-				"bacc988346c839f79513d7bc7f5c88b22ea6e7a5",
-				"90abf988d98ce0d4b162f94f63fc99c435eba6b4",
-				"a46540a2857a0fdbf43debf3383295a897946c79");
+				"org.eclipse.jgit", "1.2.0.201112221803-r", 1318000, 1354000, 3300000,
+				"f3bbea50b64c2c8e20176f412d2f063bd132878f",
+				"f6c616413540e226a6b72bc573a40410412e234f",
+				"a77e5ee65ba284d12ae444ac42e12948a9314c20");
 
 		public static final MavenObject JGIT_HTTP = new MavenObject("JGit", "org/eclipse/jgit",
-				"org.eclipse.jgit.http.server", "1.1.0.201109151100-r", 68000, 62000, 110000,
-				"3070161a89756aac2dfc2e26d89faf31fe894ab4",
-				"9cecb8e4351e616688cafbcca906f542d9b1f525",
-				"20aaab759acd8eb6cb6acbb1b2934a689fb3774d");
+				"org.eclipse.jgit.http.server", "1.2.0.201112221803-r", 68000, 62000, 110000,
+				"0d0004423b71bf7c29cd4ad85010c293c4fab95f",
+				"89be774b6db17bbc47b4757ae9e5178750064880",
+				"4cde29a085200ccf46ac677aeb1abb39352a3a6a");
 
 		public static final MavenObject JSCH = new MavenObject("JSch", "com/jcraft", "jsch",
 				"0.1.44-1", 214000, 211000, 413000, "2e9ae08de5a71bd0e0d3ba2558598181bfa71d4e",

--
Gitblit v1.9.1