}
if (line == PacketLineIn.END)
break;
if (!line.startsWith("want ") || line.length() < 45)
throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedGot, "want", line));
if (isFirst && line.length() > 45) {
String opt = line.substring(45);
if (opt.startsWith(" "))
opt = opt.substring(1);
for (String c : opt.split(" "))
options.add(c);
line = line.substring(0, 45);
}
wantIds.add(ObjectId.fromString(line.substring(5)));
isFirst = false;
}
if (wantIds.isEmpty())
return;
AsyncRevObjectQueue q = walk.parseAny(wantIds, true);
try {
for (;;) {
RevObject o;
try {
o = q.next();
} catch (IOException error) {
throw new PackProtocolException(MessageFormat.format(
JGitText.get().notValid, error.getMessage()), error);
}
if (o == null)
break;
if (o.has(WANT)) {
// Already processed, the client repeated itself.
} else if (advertised.contains(o)) {
o.add(WANT);
wantAll.add(o);
if (o instanceof RevTag) {
o = walk.peel(o);
if (o instanceof RevCommit) {
if (!o.has(WANT)) {
o.add(WANT);
wantAll.add(o);
}
}
}
} else {
throw new PackProtocolException(MessageFormat.format(
JGitText.get().notValid, o.name()));
}
}
} finally {
q.release();