diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2018-02-22 13:58:29 -0800 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2018-04-23 10:26:51 -0700 |
commit | 038765cc556b84e1bf089df5a98c1b742c176e12 (patch) | |
tree | cc4cab4c0cc8ab8481546bff4e07dd063998128b /org.eclipse.jgit.test | |
parent | a99bbf162a6e949692a1bc883be888dbeb10ab8d (diff) | |
download | jgit-038765cc556b84e1bf089df5a98c1b742c176e12.tar.gz jgit-038765cc556b84e1bf089df5a98c1b742c176e12.zip |
Teach UploadPack "ref-prefix" in "ls-refs"
Add support for the "ref-prefix" parameter in the "ls-refs" command in
the fetch-pack/upload-pack protocol v2.
Change-Id: If9cf93b2646f75d50a11b5f482594f014d59a836
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java | 39 |
1 files changed, 39 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 88ac49a51b..a50f170ffa 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 @@ -461,4 +461,43 @@ public class UploadPackTest { assertThat(pckIn.readString(), is(tag.toObjectId().getName() + " refs/tags/tag")); assertTrue(pckIn.readString() == PacketLineIn.END); } + + @Test + public void testV2LsRefsRefPrefix() throws Exception { + RevCommit tip = remote.commit().message("message").create(); + remote.update("master", tip); + remote.update("other", tip); + remote.update("yetAnother", tip); + + ByteArrayInputStream recvStream = uploadPackV2( + "command=ls-refs\n", + PacketLineIn.DELIM, + "ref-prefix refs/heads/maste", + "ref-prefix refs/heads/other", + PacketLineIn.END); + PacketLineIn pckIn = new PacketLineIn(recvStream); + + assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master")); + assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/other")); + assertTrue(pckIn.readString() == PacketLineIn.END); + } + + @Test + public void testV2LsRefsRefPrefixNoSlash() throws Exception { + RevCommit tip = remote.commit().message("message").create(); + remote.update("master", tip); + remote.update("other", tip); + + ByteArrayInputStream recvStream = uploadPackV2( + "command=ls-refs\n", + PacketLineIn.DELIM, + "ref-prefix refs/heads/maste", + "ref-prefix r", + PacketLineIn.END); + PacketLineIn pckIn = new PacketLineIn(recvStream); + + assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/master")); + assertThat(pckIn.readString(), is(tip.toObjectId().getName() + " refs/heads/other")); + assertTrue(pckIn.readString() == PacketLineIn.END); + } } |