private void readStatusReport(final Map<String, RemoteRefUpdate> refUpdates)
throws IOException {
final String unpackLine = readStringLongTimeout();
if (!unpackLine.startsWith("unpack "))
throw new PackProtocolException(uri, MessageFormat.format(JGitText.get().unexpectedReportLine, unpackLine));
final String unpackStatus = unpackLine.substring("unpack ".length());
if (!unpackStatus.equals("ok"))
throw new TransportException(uri, MessageFormat.format(
JGitText.get().errorOccurredDuringUnpackingOnTheRemoteEnd, unpackStatus));
String refLine;
while ((refLine = pckIn.readString()) != PacketLineIn.END) {
boolean ok = false;
int refNameEnd = -1;
if (refLine.startsWith("ok ")) {
ok = true;
refNameEnd = refLine.length();
} else if (refLine.startsWith("ng ")) {
ok = false;
refNameEnd = refLine.indexOf(" ", 3);
}
if (refNameEnd == -1)
throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedReportLine2
, uri, refLine));
final String refName = refLine.substring(3, refNameEnd);
final String message = (ok ? null : refLine
.substring(refNameEnd + 1));
final RemoteRefUpdate rru = refUpdates.get(refName);
if (rru == null)
throw new PackProtocolException(MessageFormat.format(JGitText.get().unexpectedRefReport, uri, refName));
if (ok) {
rru.setStatus(Status.OK);
} else {
rru.setStatus(Status.REJECTED_OTHER_REASON);
rru.setMessage(message);
}
}
for (final RemoteRefUpdate rru : refUpdates.values()) {
if (rru.getStatus() == Status.AWAITING_REPORT)
throw new PackProtocolException(MessageFormat.format(
JGitText.get().expectedReportForRefNotReceived , uri, rru.getRemoteName()));
}
}