aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2020-07-29 19:18:51 -0700
committerJonathan Nieder <jrn@google.com>2020-07-29 21:04:20 -0700
commit3c807e01580680106b7db0b1aab60e3b5d010ea4 (patch)
tree83e73be457e2ce722d73e4211b61942ee45ae89e /org.eclipse.jgit.test/tst/org/eclipse
parentdceedbcd6e66d60f095aacfa308055b7ca6f45a7 (diff)
downloadjgit-3c807e01580680106b7db0b1aab60e3b5d010ea4.tar.gz
jgit-3c807e01580680106b7db0b1aab60e3b5d010ea4.zip
Do not send empty blob in response to blob:none filter
If I create a repository containing an empty file and clone it with git clone --no-checkout --filter=blob:none \ https://url/of/repository then I would expect no blobs to be transferred over the wire. Alas, JGit rewrites filter=blob:none to filter=blob:limit=0, so if the repository contains an empty file then the empty blob gets transferred. Fix it by teaching JGit about filters based on object type to complement the existing filters based on object size. This prepares us for other future filters such as object:none. In particular, this means we do not need to look up the size of the filtered blobs, which should speed up clones. Noticed by Anna Pologova and Terry Parker. Change-Id: Id4b234921a190c108d8be2c87f54dcbfa811602a Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java8
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java18
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java2
3 files changed, 26 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
index 965a2faf8e..c0db83a820 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV0ParserTest.java
@@ -9,6 +9,10 @@
*/
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
+import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
+import static org.eclipse.jgit.lib.Constants.OBJ_TAG;
+import static org.eclipse.jgit.lib.Constants.OBJ_TREE;
import static org.eclipse.jgit.transport.ObjectIdMatcher.hasOnlyObjectIds;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
@@ -160,6 +164,10 @@ public class ProtocolV0ParserTest {
assertThat(request.getWantIds(),
hasOnlyObjectIds("4624442d68ee402a94364191085b77137618633e",
"f900c8326a43303685c46b279b9f70411bff1a4b"));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_BLOB));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TREE));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_COMMIT));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TAG));
assertEquals(13000, request.getFilterSpec().getBlobLimit());
assertEquals(-1, request.getFilterSpec().getTreeDepthLimit());
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
index 038ce717b3..837bdce919 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ProtocolV2ParserTest.java
@@ -9,6 +9,10 @@
*/
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
+import static org.eclipse.jgit.lib.Constants.OBJ_COMMIT;
+import static org.eclipse.jgit.lib.Constants.OBJ_TAG;
+import static org.eclipse.jgit.lib.Constants.OBJ_TREE;
import static org.eclipse.jgit.transport.ObjectIdMatcher.hasOnlyObjectIds;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItems;
@@ -195,7 +199,11 @@ public class ProtocolV2ParserTest {
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
FetchV2Request request = parser.parseFetchRequest(pckIn);
- assertEquals(0, request.getFilterSpec().getBlobLimit());
+ assertFalse(request.getFilterSpec().allowsType(OBJ_BLOB));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TREE));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_COMMIT));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TAG));
+ assertEquals(-1, request.getFilterSpec().getBlobLimit());
assertEquals(-1, request.getFilterSpec().getTreeDepthLimit());
}
@@ -207,6 +215,10 @@ public class ProtocolV2ParserTest {
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
FetchV2Request request = parser.parseFetchRequest(pckIn);
+ assertTrue(request.getFilterSpec().allowsType(OBJ_BLOB));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TREE));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_COMMIT));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TAG));
assertEquals(15, request.getFilterSpec().getBlobLimit());
assertEquals(-1, request.getFilterSpec().getTreeDepthLimit());
}
@@ -219,6 +231,10 @@ public class ProtocolV2ParserTest {
ProtocolV2Parser parser = new ProtocolV2Parser(
ConfigBuilder.start().allowFilter().done());
FetchV2Request request = parser.parseFetchRequest(pckIn);
+ assertTrue(request.getFilterSpec().allowsType(OBJ_BLOB));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TREE));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_COMMIT));
+ assertTrue(request.getFilterSpec().allowsType(OBJ_TAG));
assertEquals(-1, request.getFilterSpec().getBlobLimit());
assertEquals(3, request.getFilterSpec().getTreeDepthLimit());
}
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 bb33eefcee..e9b4af932e 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
@@ -127,7 +127,7 @@ public class UploadPackTest {
}
@Test
- public void testFetchWithBlobNoneFilter() throws Exception {
+ public void testFetchWithBlobZeroFilter() throws Exception {
InMemoryRepository server2 = newRepo("server2");
try (TestRepository<InMemoryRepository> remote2 = new TestRepository<>(
server2)) {