diff options
author | Jonathan Nieder <jrn@google.com> | 2020-07-29 20:40:50 -0700 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2020-07-29 20:52:12 -0700 |
commit | dceedbcd6e66d60f095aacfa308055b7ca6f45a7 (patch) | |
tree | fce75a143ba256058b510193584b414d230ae9f7 /org.eclipse.jgit | |
parent | 9fe54061197c42faedc9417bdc70797681aa06d6 (diff) | |
download | jgit-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')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/FilterSpec.java | 20 |
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; } } |