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
This commit is contained in:
parent
2fd4559773
commit
3100662a5a
|
@ -1171,6 +1171,9 @@ protected void recvCommands() throws IOException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pushCert = certParser.build();
|
pushCert = certParser.build();
|
||||||
|
if (hasCommands()) {
|
||||||
|
readPostCommands(pckIn);
|
||||||
|
}
|
||||||
} catch (PackProtocolException e) {
|
} catch (PackProtocolException e) {
|
||||||
if (sideBand) {
|
if (sideBand) {
|
||||||
try {
|
try {
|
||||||
|
@ -1217,6 +1220,16 @@ static ReceiveCommand parseCommand(String line) throws PackProtocolException {
|
||||||
return new ReceiveCommand(oldId, newId, name);
|
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. */
|
/** Enable capabilities based on a previously read capabilities line. */
|
||||||
protected void enableCapabilities() {
|
protected void enableCapabilities() {
|
||||||
sideBand = isCapabilityEnabled(CAPABILITY_SIDE_BAND_64K);
|
sideBand = isCapabilityEnabled(CAPABILITY_SIDE_BAND_64K);
|
||||||
|
|
|
@ -220,14 +220,17 @@ protected void enableCapabilities() {
|
||||||
super.enableCapabilities();
|
super.enableCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readPushOptions() throws IOException {
|
@Override
|
||||||
pushOptions = new ArrayList<>(4);
|
void readPostCommands(PacketLineIn in) throws IOException {
|
||||||
for (;;) {
|
if (usePushOptions) {
|
||||||
String option = pckIn.readString();
|
pushOptions = new ArrayList<>(4);
|
||||||
if (option == PacketLineIn.END) {
|
for (;;) {
|
||||||
break;
|
String option = in.readString();
|
||||||
|
if (option == PacketLineIn.END) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pushOptions.add(option);
|
||||||
}
|
}
|
||||||
pushOptions.add(option);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,10 +244,6 @@ private void service() throws IOException {
|
||||||
return;
|
return;
|
||||||
recvCommands();
|
recvCommands();
|
||||||
if (hasCommands()) {
|
if (hasCommands()) {
|
||||||
if (usePushOptions) {
|
|
||||||
readPushOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
Throwable unpackError = null;
|
Throwable unpackError = null;
|
||||||
if (needPack()) {
|
if (needPack()) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue