diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2019-01-22 13:17:12 -0800 |
---|---|---|
committer | Jonathan Tan <jonathantanmy@google.com> | 2019-07-16 11:13:30 -0700 |
commit | 79d776429e36e29956b88178e42dd23ee96ddf36 (patch) | |
tree | 1101e28b2df611755c752b0490ad56638d877b43 /org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java | |
parent | c1ed69de4ae53d04a27c5c10c00371eefc1774fd (diff) | |
download | jgit-79d776429e36e29956b88178e42dd23ee96ddf36.tar.gz jgit-79d776429e36e29956b88178e42dd23ee96ddf36.zip |
Support "sideband-all" in protocol v2 fetch
Allow the client to specify "sideband-all" in a fetch v2 request,
indicating that the whole response is to be multiplexed (with a sideband
indicator on every non-flush and non-delim pkt) instead of only the
packfile being multiplexed. This allows, for example, progress messages
to be sent at any point in the response.
This implements the "sideband-all" feature documented in
Documentation/technical/protocol-v2.txt in Git.
Change-Id: I3e7f21c88ff0982b1b7ebb09c9ad6c742c4483c8
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java | 58 |
1 files changed, 58 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 a80990d6d1..7b952e8cf1 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 @@ -595,6 +595,12 @@ public class UploadPackTest { } @Test + public void testV2CapabilitiesAllowSidebandAll() throws Exception { + checkAdvertisedIfAllowed("uploadpack", "allowsidebandall", "sideband-all"); + checkUnadvertisedIfUnallowed("sideband-all"); + } + + @Test public void testV2CapabilitiesRefInWantNotAdvertisedIfAdvertisingForbidden() throws Exception { server.getConfig().setBoolean("uploadpack", null, "allowrefinwant", true); server.getConfig().setBoolean("uploadpack", null, "advertiserefinwant", false); @@ -1875,6 +1881,13 @@ public class UploadPackTest { } @Test + public void testV2FetchSidebandAllIfNotAllowed() throws Exception { + checkV2FetchWhenNotAllowed( + "sideband-all\n", + "unexpected sideband-all"); + } + + @Test public void testV2FetchWantRef() throws Exception { RevCommit one = remote.commit().message("1").create(); RevCommit two = remote.commit().message("2").create(); @@ -2058,6 +2071,51 @@ public class UploadPackTest { } @Test + public void testV2FetchSidebandAllNoPackfile() throws Exception { + RevCommit fooParent = remote.commit().message("x").create(); + RevCommit fooChild = remote.commit().message("x").parent(fooParent).create(); + RevCommit barParent = remote.commit().message("y").create(); + RevCommit barChild = remote.commit().message("y").parent(barParent).create(); + remote.update("branch1", fooChild); + remote.update("branch2", barChild); + + server.getConfig().setBoolean("uploadpack", null, "allowsidebandall", true); + + ByteArrayInputStream recvStream = uploadPackV2( + "command=fetch\n", + PacketLineIn.DELIM, + "sideband-all\n", + "want " + fooChild.toObjectId().getName() + "\n", + "want " + barChild.toObjectId().getName() + "\n", + "have " + fooParent.toObjectId().getName() + "\n", + PacketLineIn.END); + PacketLineIn pckIn = new PacketLineIn(recvStream); + + assertThat(pckIn.readString(), is("\001acknowledgments")); + assertThat(pckIn.readString(), is("\001ACK " + fooParent.getName())); + assertTrue(PacketLineIn.isEnd(pckIn.readString())); + } + + @Test + public void testV2FetchSidebandAllPackfile() throws Exception { + RevCommit commit = remote.commit().message("x").create(); + remote.update("master", commit); + + server.getConfig().setBoolean("uploadpack", null, "allowsidebandall", true); + + ByteArrayInputStream recvStream = uploadPackV2("command=fetch\n", + PacketLineIn.DELIM, + "want " + commit.getName() + "\n", + "sideband-all\n", + "done\n", + PacketLineIn.END); + PacketLineIn pckIn = new PacketLineIn(recvStream); + + assertThat(pckIn.readString(), is("\001packfile")); + parsePack(recvStream); + } + + @Test public void testGetPeerAgentProtocolV0() throws Exception { RevCommit one = remote.commit().message("1").create(); remote.update("one", one); |