summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2020-07-29 20:40:50 -0700
committerJonathan Nieder <jrn@google.com>2020-07-29 20:52:12 -0700
commitdceedbcd6e66d60f095aacfa308055b7ca6f45a7 (patch)
treefce75a143ba256058b510193584b414d230ae9f7 /org.eclipse.jgit.test
parent9fe54061197c42faedc9417bdc70797681aa06d6 (diff)
downloadjgit-dceedbcd6e66d60f095aacfa308055b7ca6f45a7.tar.gz
jgit-dceedbcd6e66d60f095aacfa308055b7ca6f45a7.zip
Add support for tree filters when fetching
Teach the FilterSpec serialization code about tree filters so they can be communicated over the wire and understood by the server. While we're here, harden the FilterSpec serialization code to throw IllegalStateException if we encounter a FilterSpec that cannot be expressed as a "filter" line. The only public API for creating a Filterspec is to pass in a "filter" line to be parsed, so these should not appear in practice. Change-Id: I9664844059ffbc9c36eb829e2d860f198b9403a0 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.java32
1 files changed, 32 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 d58e576984..bb33eefcee 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
@@ -298,6 +298,38 @@ public class UploadPackTest {
}
@Test
+ public void testFetchWithTreeZeroFilter() throws Exception {
+ InMemoryRepository server2 = newRepo("server2");
+ try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
+ server2)) {
+ RevBlob blob1 = remote2.blob("foobar");
+ RevBlob blob2 = remote2.blob("fooba");
+ RevTree tree = remote2.tree(remote2.file("1", blob1),
+ remote2.file("2", blob2));
+ RevCommit commit = remote2.commit(tree);
+ remote2.update("master", commit);
+
+ server2.getConfig().setBoolean("uploadpack", null, "allowfilter",
+ true);
+
+ testProtocol = new TestProtocol<>((Object req, Repository db) -> {
+ UploadPack up = new UploadPack(db);
+ return up;
+ }, null);
+ uri = testProtocol.register(ctx, server2);
+
+ try (Transport tn = testProtocol.open(uri, client, "server2")) {
+ tn.setFilterSpec(FilterSpec.withTreeDepthLimit(0));
+ tn.fetch(NullProgressMonitor.INSTANCE,
+ Collections.singletonList(new RefSpec(commit.name())));
+ assertFalse(client.getObjectDatabase().has(tree.toObjectId()));
+ assertFalse(client.getObjectDatabase().has(blob1.toObjectId()));
+ assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
+ }
+ }
+ }
+
+ @Test
public void testFetchWithNonSupportingServer() throws Exception {
InMemoryRepository server2 = newRepo("server2");
try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(