diff options
author | Shawn Pearce <spearce@spearce.org> | 2016-08-29 12:11:11 -0700 |
---|---|---|
committer | Shawn Pearce <spearce@spearce.org> | 2016-08-29 12:31:22 -0700 |
commit | 3100662a5acb0f7c21035c69841df0e645c62466 (patch) | |
tree | 81d3544375d5e052e2220be2d55c0a5cb0e3a9db | |
parent | 2fd4559773cecc803dc0c27a5cc801dc6575981f (diff) | |
download | jgit-3100662a5acb0f7c21035c69841df0e645c62466.tar.gz jgit-3100662a5acb0f7c21035c69841df0e645c62466.zip |
ReceivePack: integrate push option parsing into recvCommands
This allows the same try/catch to handle parsing the command list,
push certificate and push options. Any errors will be caught and
handled by the same catch block, as the client is in the same state.
Change-Id: I13a66f9100e2dc8ca8f72cd701a5bd44d093ec84
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java | 13 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java | 21 |
2 files changed, 23 insertions, 11 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 5a61edd6ab..0724eac701 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -1171,6 +1171,9 @@ public abstract class BaseReceivePack { } } pushCert = certParser.build(); + if (hasCommands()) { + readPostCommands(pckIn); + } } catch (PackProtocolException e) { if (sideBand) { try { @@ -1217,6 +1220,16 @@ public abstract class BaseReceivePack { return new ReceiveCommand(oldId, newId, name); } + /** + * @param in + * request stream. + * @throws IOException + * request line cannot be read. + */ + void readPostCommands(PacketLineIn in) throws IOException { + // Do nothing by default. + } + /** Enable capabilities based on a previously read capabilities line. */ protected void enableCapabilities() { sideBand = isCapabilityEnabled(CAPABILITY_SIDE_BAND_64K); 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 2e3d74a147..cc20d50a7f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/ReceivePack.java @@ -220,14 +220,17 @@ public class ReceivePack extends BaseReceivePack { super.enableCapabilities(); } - private void readPushOptions() throws IOException { - pushOptions = new ArrayList<>(4); - for (;;) { - String option = pckIn.readString(); - if (option == PacketLineIn.END) { - break; + @Override + void readPostCommands(PacketLineIn in) throws IOException { + if (usePushOptions) { + pushOptions = new ArrayList<>(4); + for (;;) { + String option = in.readString(); + if (option == PacketLineIn.END) { + break; + } + pushOptions.add(option); } - pushOptions.add(option); } } @@ -241,10 +244,6 @@ public class ReceivePack extends BaseReceivePack { return; recvCommands(); if (hasCommands()) { - if (usePushOptions) { - readPushOptions(); - } - Throwable unpackError = null; if (needPack()) { try { |