summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-03-13 11:07:36 -0700
committerJonathan Nieder <jrn@google.com>2018-05-16 17:16:35 -0700
commit5a87d50408642f619b77d12a981e6e23f407752e (patch)
tree333ed656d77c2055345cbd8d0b9f44d7be583694 /org.eclipse.jgit.test
parentc79e7f1c27c73732310bc64c2071a79902447dcc (diff)
downloadjgit-5a87d50408642f619b77d12a981e6e23f407752e.tar.gz
jgit-5a87d50408642f619b77d12a981e6e23f407752e.zip
Teach UploadPack "include-tag" in "fetch"
Add support for the "include-tag" parameter in the "fetch" command in the fetch-pack/upload-pack protocol v2. In order to determine which tags to include, only objects pointed to by refs starting with "refs/tags/" are checked. This restriction is for performance reasons and to match the behavior of Git (see add_ref_tag() in builtin/pack-objects.c). Change-Id: I7d70aa09bcc8a525218ff1559e286c2a610258ca Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java33
1 files changed, 33 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 5073e0ed33..5ae93fc12d 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
@@ -805,6 +805,39 @@ public class UploadPackTest {
assertTrue(sw.toString().isEmpty());
}
+ @Test
+ public void testV2FetchIncludeTag() throws Exception {
+ RevCommit commit = remote.commit().message("x").create();
+ RevTag tag = remote.tag("tag", commit);
+ remote.update("branch1", commit);
+ remote.update("refs/tags/tag", tag);
+
+ // Without include-tag.
+ ByteArrayInputStream recvStream = uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "want " + commit.toObjectId().getName() + "\n",
+ "done\n",
+ PacketLineIn.END);
+ PacketLineIn pckIn = new PacketLineIn(recvStream);
+ assertThat(pckIn.readString(), is("packfile"));
+ parsePack(recvStream);
+ assertFalse(client.hasObject(tag.toObjectId()));
+
+ // With tag.
+ recvStream = uploadPackV2(
+ "command=fetch\n",
+ PacketLineIn.DELIM,
+ "want " + commit.toObjectId().getName() + "\n",
+ "include-tag\n",
+ "done\n",
+ PacketLineIn.END);
+ pckIn = new PacketLineIn(recvStream);
+ assertThat(pckIn.readString(), is("packfile"));
+ parsePack(recvStream);
+ assertTrue(client.hasObject(tag.toObjectId()));
+ }
+
private static class RejectAllRefFilter implements RefFilter {
@Override
public Map<String, Ref> filter(Map<String, Ref> refs) {