diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2012-06-27 11:06:37 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2012-06-27 14:11:42 -0700 |
commit | 1c6c73c5a9b8dd700be45d658f165a464265dba7 (patch) | |
tree | 9dddd8e9bbf31cf23ad946f91468fed0ac19ef3f /org.eclipse.jgit | |
parent | dc23a7cc421f09da42192c54ea8d54fb2ca30dfb (diff) | |
download | jgit-1c6c73c5a9b8dd700be45d658f165a464265dba7.tar.gz jgit-1c6c73c5a9b8dd700be45d658f165a464265dba7.zip |
Work around smart HTTP bugs in C Git
I have unfortunately introduced a few bugs in the native Git client
over the years. 1.7.5 is unable to send chunked requests correctly,
resulting in corrupt data at the server. Ban this client whenever
it uses chunked encoding with an error message.
Prior to some more recent versions, git push over HTTP failed to
report status information and error messages due to a race within
the client and its helper process. Check for these bad versions and
send errors as messages before the status report, enabling users
to see the failures on their terminal.
Change-Id: Ic62d6591cbd851d21dbb3e9b023d655eaecb0624
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java | 9 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 26 |
2 files changed, 32 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index 12ad733b0f..60e79ce959 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -1210,9 +1210,10 @@ public abstract class BaseReceivePack { } final StringBuilder r = new StringBuilder(); - r.append("ng "); - r.append(cmd.getRefName()); - r.append(" "); + if (forClient) + r.append("ng ").append(cmd.getRefName()).append(" "); + else + r.append(" ! [rejected] ").append(cmd.getRefName()).append(" ("); switch (cmd.getResult()) { case NOT_ATTEMPTED: @@ -1259,6 +1260,8 @@ public abstract class BaseReceivePack { // We shouldn't have reached this case (see 'ok' case above). continue; } + if (!forClient) + r.append(")"); out.sendString(r.toString()); } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java index 99e629a135..9630f78532 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -63,6 +63,8 @@ public class ReceivePack extends BaseReceivePack { /** Hook to report on the commands after execution. */ private PostReceiveHook postReceive; + private boolean echoCommandFailures; + /** * Create a new pack receive for an open repository. * @@ -118,6 +120,17 @@ public class ReceivePack extends BaseReceivePack { } /** + * @param echo + * if true this class will report command failures as warning + * 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. + */ + public void setEchoCommandFailures(boolean echo) { + echoCommandFailures = echo; + } + + /** * Execute the receive task on the socket. * * @param input @@ -182,6 +195,19 @@ public class ReceivePack extends BaseReceivePack { unlockPack(); if (reportStatus) { + if (echoCommandFailures && msgOut != null) { + sendStatusReport(false, unpackError, new Reporter() { + void sendString(final String s) throws IOException { + msgOut.write(Constants.encode(s + "\n")); + } + }); + msgOut.flush(); + try { + Thread.sleep(500); + } catch (InterruptedException wakeUp) { + // Ignore an early wake up. + } + } sendStatusReport(true, unpackError, new Reporter() { void sendString(final String s) throws IOException { pckOut.writeString(s + "\n"); |