summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java91
3 files changed, 54 insertions, 48 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
index 41217d9971..c88670ec97 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ReceivePackServlet.java
@@ -76,6 +76,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.errors.CorruptObjectException;
+import org.eclipse.jgit.errors.PackProtocolException;
import org.eclipse.jgit.errors.UnpackException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.InternalHttpServerGlue;
@@ -200,7 +201,7 @@ class ReceivePackServlet extends HttpServlet {
consumeRequestBody(req);
out.close();
- } catch (UnpackException e) {
+ } catch (UnpackException | PackProtocolException e) {
// This should be already reported to the client.
log(rp.getRepository(), e.getCause());
consumeRequestBody(req);
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java
index 5503bd19e2..44bc16492d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/errors/PackProtocolException.java
@@ -60,7 +60,7 @@ public class PackProtocolException extends TransportException {
* @param uri
* URI used for transport
* @param s
- * message
+ * message, which may be shown to an end-user.
*/
public PackProtocolException(final URIish uri, final String s) {
super(uri + ": " + s); //$NON-NLS-1$
@@ -73,7 +73,7 @@ public class PackProtocolException extends TransportException {
* @param uri
* URI used for transport
* @param s
- * message
+ * message, which may be shown to an end-user.
* @param cause
* root cause exception
*/
@@ -86,7 +86,7 @@ public class PackProtocolException extends TransportException {
* Constructs an PackProtocolException with the specified detail message.
*
* @param s
- * message
+ * message, which may be shown to an end-user.
*/
public PackProtocolException(final String s) {
super(s);
@@ -96,7 +96,7 @@ public class PackProtocolException extends TransportException {
* Constructs an PackProtocolException with the specified detail message.
*
* @param s
- * message
+ * message, which may be shown to an end-user.
* @param cause
* root cause exception
*/
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 36d335503a..518a3178f6 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -1065,56 +1065,61 @@ public abstract class BaseReceivePack {
protected void recvCommands() throws IOException {
PushCertificateParser certParser = getPushCertificateParser();
FirstLine firstLine = null;
- for (;;) {
- String line;
- try {
- line = pckIn.readString();
- } catch (EOFException eof) {
- if (commands.isEmpty())
- return;
- throw eof;
- }
- if (line == PacketLineIn.END) {
- break;
- }
+ try {
+ for (;;) {
+ String line;
+ try {
+ line = pckIn.readString();
+ } catch (EOFException eof) {
+ if (commands.isEmpty())
+ return;
+ throw eof;
+ }
+ if (line == PacketLineIn.END) {
+ break;
+ }
- if (line.length() >= 48 && line.startsWith("shallow ")) { //$NON-NLS-1$
- clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48)));
- continue;
- }
+ if (line.length() >= 48 && line.startsWith("shallow ")) { //$NON-NLS-1$
+ clientShallowCommits.add(ObjectId.fromString(line.substring(8, 48)));
+ continue;
+ }
- if (firstLine == null) {
- firstLine = new FirstLine(line);
- enabledCapabilities = firstLine.getCapabilities();
- line = firstLine.getLine();
+ if (firstLine == null) {
+ firstLine = new FirstLine(line);
+ enabledCapabilities = firstLine.getCapabilities();
+ line = firstLine.getLine();
- if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) {
- certParser.receiveHeader(pckIn, !isBiDirectionalPipe());
- continue;
+ if (line.equals(GitProtocolConstants.OPTION_PUSH_CERT)) {
+ certParser.receiveHeader(pckIn, !isBiDirectionalPipe());
+ continue;
+ }
}
- }
- if (line.equals(PushCertificateParser.BEGIN_SIGNATURE)) {
- certParser.receiveSignature(pckIn);
- continue;
- }
+ if (line.equals(PushCertificateParser.BEGIN_SIGNATURE)) {
+ certParser.receiveSignature(pckIn);
+ continue;
+ }
- ReceiveCommand cmd;
- try {
- cmd = parseCommand(line);
- } catch (PackProtocolException e) {
- sendError(e.getMessage());
- throw e;
- }
- if (cmd.getRefName().equals(Constants.HEAD)) {
- cmd.setResult(Result.REJECTED_CURRENT_BRANCH);
- } else {
- cmd.setRef(refs.get(cmd.getRefName()));
- }
- commands.add(cmd);
- if (certParser.enabled()) {
- certParser.addCommand(cmd);
+ ReceiveCommand cmd;
+ try {
+ cmd = parseCommand(line);
+ } catch (PackProtocolException e) {
+ sendError(e.getMessage());
+ throw e;
+ }
+ if (cmd.getRefName().equals(Constants.HEAD)) {
+ cmd.setResult(Result.REJECTED_CURRENT_BRANCH);
+ } else {
+ cmd.setRef(refs.get(cmd.getRefName()));
+ }
+ commands.add(cmd);
+ if (certParser.enabled()) {
+ certParser.addCommand(cmd);
+ }
}
+ } catch (PackProtocolException e) {
+ sendError(e.getMessage());
+ throw e;
}
}