Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder2020-07-30 03:40:50 +0000
committerJonathan Nieder2020-07-30 03:52:12 +0000
commitdceedbcd6e66d60f095aacfa308055b7ca6f45a7 (patch)
treefce75a143ba256058b510193584b414d230ae9f7 /org.eclipse.jgit/src
parent9fe54061197c42faedc9417bdc70797681aa06d6 (diff)
downloadjgit-dceedbcd6e66d60f095aacfa308055b7ca6f45a7.tar.gz
jgit-dceedbcd6e66d60f095aacfa308055b7ca6f45a7.tar.xz
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/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FilterSpec.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FilterSpec.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FilterSpec.java
index d09b5579fa..51e5a8f20c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FilterSpec.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FilterSpec.java
@@ -10,6 +10,8 @@
package org.eclipse.jgit.transport;
+import static org.eclipse.jgit.transport.GitProtocolConstants.OPTION_FILTER;
+
import java.text.MessageFormat;
import org.eclipse.jgit.annotations.Nullable;
@@ -146,14 +148,16 @@ public final class FilterSpec {
*/
@Nullable
public String filterLine() {
- if (blobLimit == 0) {
- return GitProtocolConstants.OPTION_FILTER + " blob:none"; //$NON-NLS-1$
- }
-
- if (blobLimit > 0) {
- return GitProtocolConstants.OPTION_FILTER + " blob:limit=" + blobLimit; //$NON-NLS-1$
+ if (isNoOp()) {
+ return null;
+ } else if (blobLimit == 0 && treeDepthLimit == -1) {
+ return OPTION_FILTER + " blob:none"; //$NON-NLS-1$
+ } else if (blobLimit > 0 && treeDepthLimit == -1) {
+ return OPTION_FILTER + " blob:limit=" + blobLimit; //$NON-NLS-1$
+ } else if (blobLimit == -1 && treeDepthLimit >= 0) {
+ return OPTION_FILTER + " tree:" + treeDepthLimit; //$NON-NLS-1$
+ } else {
+ throw new IllegalStateException();
}
-
- return null;
}
}

Back to the top