Browse Source

Revert C Git 1.7.5 bug workaround

This reverts the workaround introduced by
1c6c73c5a9, which is a patch for dealing
with a buggy C Git client v1.7.5 in 2012. We'll stop supporting very old
C Git clients.

Change-Id: I94999a39101c96f210b5eca3c2f620c15eb1ac1b
Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
stable-5.2
Masaya Suzuki 6 years ago
parent
commit
49befd84d7
  1. 22
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ClientVersionUtil.java
  2. 12
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
  3. 10
      org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java
  4. 15
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/server/ClientVersionUtilTest.java
  5. 20
      org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

22
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ClientVersionUtil.java

@ -43,18 +43,12 @@
package org.eclipse.jgit.http.server;
import static org.eclipse.jgit.http.server.ServletUtils.isChunked;
import javax.servlet.http.HttpServletRequest;
/**
* Parses Git client User-Agent strings.
*/
public class ClientVersionUtil {
private static final int[] v1_7_5 = { 1, 7, 5 };
private static final int[] v1_7_8_6 = { 1, 7, 8, 6 };
private static final int[] v1_7_9 = { 1, 7, 9 };
/**
* An invalid version of Git
*
@ -174,17 +168,11 @@ public class ClientVersionUtil {
* @param version
* parsed version of the Git client software.
* @return true if the bug is present.
* @deprecated no widely used Git versions need this any more
*/
@Deprecated
public static boolean hasPushStatusBug(int[] version) {
int cmp = compare(version, v1_7_8_6);
if (cmp < 0)
return true; // Everything before 1.7.8.6 is known broken.
else if (cmp == 0)
return false; // 1.7.8.6 contained the bug fix.
if (compare(version, v1_7_9) <= 0)
return true; // 1.7.9 shipped before 1.7.8.6 and has the bug.
return false; // 1.7.9.1 and later are fixed.
return false;
}
/**
@ -198,10 +186,12 @@ public class ClientVersionUtil {
* @param request
* incoming HTTP request.
* @return true if the client has the chunked encoding bug.
* @deprecated no widely used Git versions need this any more
*/
@Deprecated
public static boolean hasChunkedEncodingRequestBug(
int[] version, HttpServletRequest request) {
return compare(version, v1_7_5) == 0 && isChunked(request);
return false;
}
private ClientVersionUtil() {

12
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java

@ -43,14 +43,10 @@
package org.eclipse.jgit.http.server;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import static javax.servlet.http.HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE;
import static org.eclipse.jgit.http.server.ClientVersionUtil.hasChunkedEncodingRequestBug;
import static org.eclipse.jgit.http.server.ClientVersionUtil.hasPushStatusBug;
import static org.eclipse.jgit.http.server.ClientVersionUtil.parseVersion;
import static org.eclipse.jgit.http.server.GitSmartHttpTools.RECEIVE_PACK;
import static org.eclipse.jgit.http.server.GitSmartHttpTools.RECEIVE_PACK_REQUEST_TYPE;
import static org.eclipse.jgit.http.server.GitSmartHttpTools.RECEIVE_PACK_RESULT_TYPE;
@ -174,13 +170,6 @@ class ReceivePackServlet extends HttpServlet {
return;
}
int[] version = parseVersion(req.getHeader(HDR_USER_AGENT));
if (hasChunkedEncodingRequestBug(version, req)) {
GitSmartHttpTools.sendError(req, rsp, SC_BAD_REQUEST, "\n\n"
+ HttpServerText.get().clientHas175ChunkedEncodingBug);
return;
}
SmartOutputStream out = new SmartOutputStream(req, rsp, false) {
@Override
public void flush() throws IOException {
@ -191,7 +180,6 @@ class ReceivePackServlet extends HttpServlet {
ReceivePack rp = (ReceivePack) req.getAttribute(ATTRIBUTE_HANDLER);
try {
rp.setBiDirectionalPipe(false);
rp.setEchoCommandFailures(hasPushStatusBug(version));
rsp.setContentType(RECEIVE_PACK_RESULT_TYPE);
rp.receive(getInputStream(req), out, null);

10
org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/UploadPackServlet.java

@ -43,13 +43,10 @@
package org.eclipse.jgit.http.server;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static javax.servlet.http.HttpServletResponse.SC_UNAUTHORIZED;
import static javax.servlet.http.HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE;
import static org.eclipse.jgit.http.server.ClientVersionUtil.hasChunkedEncodingRequestBug;
import static org.eclipse.jgit.http.server.ClientVersionUtil.parseVersion;
import static org.eclipse.jgit.http.server.GitSmartHttpTools.UPLOAD_PACK;
import static org.eclipse.jgit.http.server.GitSmartHttpTools.UPLOAD_PACK_REQUEST_TYPE;
import static org.eclipse.jgit.http.server.GitSmartHttpTools.UPLOAD_PACK_RESULT_TYPE;
@ -193,13 +190,6 @@ class UploadPackServlet extends HttpServlet {
return;
}
int[] version = parseVersion(req.getHeader(HDR_USER_AGENT));
if (hasChunkedEncodingRequestBug(version, req)) {
GitSmartHttpTools.sendError(req, rsp, SC_BAD_REQUEST, "\n\n"
+ HttpServerText.get().clientHas175ChunkedEncodingBug);
return;
}
SmartOutputStream out = new SmartOutputStream(req, rsp, false) {
@Override
public void flush() throws IOException {

15
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/server/ClientVersionUtilTest.java

@ -43,11 +43,8 @@
package org.eclipse.jgit.http.server;
import static org.eclipse.jgit.http.server.ClientVersionUtil.hasPushStatusBug;
import static org.eclipse.jgit.http.server.ClientVersionUtil.invalidVersion;
import static org.eclipse.jgit.http.server.ClientVersionUtil.parseVersion;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Assert;
import org.junit.Test;
@ -67,18 +64,6 @@ public class ClientVersionUtilTest {
assertEquals(ClientVersionUtil.toString(invalidVersion()), parseVersion("foo"));
}
@Test
public void testPushStatusBug() {
assertTrue(hasPushStatusBug(parseVersion("git/1.6.6")));
assertTrue(hasPushStatusBug(parseVersion("git/1.6.6.1")));
assertTrue(hasPushStatusBug(parseVersion("git/1.7.9")));
assertFalse(hasPushStatusBug(parseVersion("git/1.7.8.6")));
assertFalse(hasPushStatusBug(parseVersion("git/1.7.9.1")));
assertFalse(hasPushStatusBug(parseVersion("git/1.7.9.2")));
assertFalse(hasPushStatusBug(parseVersion("git/1.7.10")));
}
private static void assertEquals(String exp, int[] act) {
Assert.assertEquals(exp, ClientVersionUtil.toString(act));
}

20
org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java

@ -76,8 +76,6 @@ public class ReceivePack extends BaseReceivePack {
/** If {@link BasePackPushConnection#CAPABILITY_REPORT_STATUS} is enabled. */
private boolean reportStatus;
private boolean echoCommandFailures;
/** Whether the client intends to use push options. */
private boolean usePushOptions;
private List<String> pushOptions;
@ -191,9 +189,11 @@ public class ReceivePack extends BaseReceivePack {
* messages before sending the command results. This is usually
* not necessary, but may help buggy Git clients that discard the
* errors when all branches fail.
* @deprecated no widely used Git versions need this any more
*/
@Deprecated
public void setEchoCommandFailures(boolean echo) {
echoCommandFailures = echo;
// No-op.
}
/**
@ -291,20 +291,6 @@ public class ReceivePack extends BaseReceivePack {
}
if (reportStatus) {
if (echoCommandFailures && msgOut != null) {
sendStatusReport(false, unpackError, new Reporter() {
@Override
void sendString(String s) throws IOException {
msgOut.write(Constants.encode(s + "\n")); //$NON-NLS-1$
}
});
msgOut.flush();
try {
Thread.sleep(500);
} catch (InterruptedException wakeUp) {
// Ignore an early wake up.
}
}
sendStatusReport(true, unpackError, new Reporter() {
@Override
void sendString(String s) throws IOException {

Loading…
Cancel
Save