Merge branch 'stable-5.13' into stable-6.0
* stable-5.13: UploadPack v2 protocol: Stop negotiation for orphan refs Change-Id: I6a9ed8338ffbf5363e48d640a2c4209e4e503549
This commit is contained in:
commit
de1abd3237
|
@ -1106,6 +1106,61 @@ public void testV2FetchWithWaitForDoneOnlyDoesNegotiationAndNothingToAck()
|
||||||
assertTrue(PacketLineIn.isEnd(pckIn.readString()));
|
assertTrue(PacketLineIn.isEnd(pckIn.readString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testV2FetchServerStopsNegotiationForRefWithoutParents()
|
||||||
|
throws Exception {
|
||||||
|
RevCommit fooCommit = remote.commit().message("x").create();
|
||||||
|
RevCommit barCommit = remote.commit().message("y").create();
|
||||||
|
remote.update("refs/changes/01/1/1", fooCommit);
|
||||||
|
remote.update("refs/changes/02/2/1", barCommit);
|
||||||
|
|
||||||
|
ByteArrayInputStream recvStream = uploadPackV2("command=fetch\n",
|
||||||
|
PacketLineIn.delimiter(),
|
||||||
|
"want " + fooCommit.toObjectId().getName() + "\n",
|
||||||
|
"have " + barCommit.toObjectId().getName() + "\n",
|
||||||
|
PacketLineIn.end());
|
||||||
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
|
|
||||||
|
assertThat(pckIn.readString(), is("acknowledgments"));
|
||||||
|
assertThat(pckIn.readString(),
|
||||||
|
is("ACK " + barCommit.toObjectId().getName()));
|
||||||
|
assertThat(pckIn.readString(), is("ready"));
|
||||||
|
assertTrue(PacketLineIn.isDelimiter(pckIn.readString()));
|
||||||
|
assertThat(pckIn.readString(), is("packfile"));
|
||||||
|
parsePack(recvStream);
|
||||||
|
assertTrue(client.getObjectDatabase().has(fooCommit.toObjectId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testV2FetchServerDoesNotStopNegotiationWhenOneRefWithoutParentAndOtherWithParents()
|
||||||
|
throws Exception {
|
||||||
|
RevCommit fooCommit = remote.commit().message("x").create();
|
||||||
|
RevCommit barParent = remote.commit().message("y").create();
|
||||||
|
RevCommit barChild = remote.commit().message("y").parent(barParent)
|
||||||
|
.create();
|
||||||
|
RevCommit fooBarParent = remote.commit().message("z").create();
|
||||||
|
RevCommit fooBarChild = remote.commit().message("y")
|
||||||
|
.parent(fooBarParent)
|
||||||
|
.create();
|
||||||
|
remote.update("refs/changes/01/1/1", fooCommit);
|
||||||
|
remote.update("refs/changes/02/2/1", barChild);
|
||||||
|
remote.update("refs/changes/03/3/1", fooBarChild);
|
||||||
|
|
||||||
|
ByteArrayInputStream recvStream = uploadPackV2("command=fetch\n",
|
||||||
|
PacketLineIn.delimiter(),
|
||||||
|
"want " + fooCommit.toObjectId().getName() + "\n",
|
||||||
|
"want " + barChild.toObjectId().getName() + "\n",
|
||||||
|
"want " + fooBarChild.toObjectId().getName() + "\n",
|
||||||
|
"have " + fooBarParent.toObjectId().getName() + "\n",
|
||||||
|
PacketLineIn.end());
|
||||||
|
PacketLineIn pckIn = new PacketLineIn(recvStream);
|
||||||
|
|
||||||
|
assertThat(pckIn.readString(), is("acknowledgments"));
|
||||||
|
assertThat(pckIn.readString(),
|
||||||
|
is("ACK " + fooBarParent.toObjectId().getName()));
|
||||||
|
assertTrue(PacketLineIn.isEnd(pckIn.readString()));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testV2FetchThinPack() throws Exception {
|
public void testV2FetchThinPack() throws Exception {
|
||||||
String commonInBlob = "abcdefghijklmnopqrstuvwxyz";
|
String commonInBlob = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
|
@ -2175,6 +2175,11 @@ private boolean wantSatisfied(RevObject want) throws IOException {
|
||||||
if (want.has(SATISFIED))
|
if (want.has(SATISFIED))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (((RevCommit) want).getParentCount() == 0) {
|
||||||
|
want.add(SATISFIED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
walk.resetRetain(SAVE);
|
walk.resetRetain(SAVE);
|
||||||
walk.markStart((RevCommit) want);
|
walk.markStart((RevCommit) want);
|
||||||
if (oldestTime != 0)
|
if (oldestTime != 0)
|
||||||
|
|
Loading…
Reference in New Issue