Merge "UploadPack: consume delimiter in object-info command"

This commit is contained in:
Han-Wen NIenhuys 2023-02-02 09:09:25 -05:00 committed by Gerrit Code Review @ Eclipse.org
commit a1fa0ee679
2 changed files with 9 additions and 1 deletions

View File

@ -2766,7 +2766,9 @@ public void testObjectInfo() throws Exception {
TestV2Hook hook = new TestV2Hook();
ByteArrayInputStream recvStream = uploadPackV2((UploadPack up) -> {
up.setProtocolV2Hook(hook);
}, "command=object-info\n", "size",
}, "command=object-info\n",
PacketLineIn.delimiter(),
"size",
"oid " + ObjectId.toString(blob1.getId()),
"oid " + ObjectId.toString(blob2.getId()), PacketLineIn.end());
PacketLineIn pckIn = new PacketLineIn(recvStream);

View File

@ -281,6 +281,12 @@ ObjectInfoRequest parseObjectInfoRequest(PacketLineIn pckIn)
return builder.build();
}
if (!PacketLineIn.isDelimiter(line)) {
throw new PackProtocolException(MessageFormat
.format(JGitText.get().unexpectedPacketLine, line));
}
line = pckIn.readString();
if (!line.equals("size")) { //$NON-NLS-1$
throw new PackProtocolException(MessageFormat
.format(JGitText.get().unexpectedPacketLine, line));