aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-01-18 17:51:14 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2022-01-18 17:51:14 +0100
commit2cc0009737182822a82731f523c0f6ded7601ddb (patch)
tree87683aae84f55870f2969080ccc3ca00543b3e52 /org.eclipse.jgit.test/tst
parent486afbc08d4689105019f77bf1ca0d1a2fc5ab0f (diff)
parent1e59cabc08ffddaae7129f0407f7ae17f01c5d90 (diff)
downloadjgit-2cc0009737182822a82731f523c0f6ded7601ddb.tar.gz
jgit-2cc0009737182822a82731f523c0f6ded7601ddb.zip
Merge branch 'stable-5.12' into stable-5.13
* stable-5.12: UploadPack v2 protocol: Stop negotiation for orphan refs Change-Id: Ib43068c32d9cb8effe4b873396391dc3c9197a6e
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
index f4bbb4c9f8..127711ff91 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
@@ -1108,6 +1108,61 @@ public class UploadPackTest {
}
@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
public void testV2FetchThinPack() throws Exception {
String commonInBlob = "abcdefghijklmnopqrstuvwxyz";