@ -44,6 +44,7 @@
package org.eclipse.jgit.internal.storage.pack ;
package org.eclipse.jgit.internal.storage.pack ;
import static java.util.Objects.requireNonNull ;
import static org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation.PACK_DELTA ;
import static org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation.PACK_DELTA ;
import static org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation.PACK_WHOLE ;
import static org.eclipse.jgit.internal.storage.pack.StoredObjectRepresentation.PACK_WHOLE ;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH ;
import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH ;
@ -119,6 +120,7 @@ import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.revwalk.RevTree ;
import org.eclipse.jgit.revwalk.RevTree ;
import org.eclipse.jgit.storage.pack.PackConfig ;
import org.eclipse.jgit.storage.pack.PackConfig ;
import org.eclipse.jgit.storage.pack.PackStatistics ;
import org.eclipse.jgit.storage.pack.PackStatistics ;
import org.eclipse.jgit.transport.FilterSpec ;
import org.eclipse.jgit.transport.ObjectCountCallback ;
import org.eclipse.jgit.transport.ObjectCountCallback ;
import org.eclipse.jgit.transport.WriteAbortedException ;
import org.eclipse.jgit.transport.WriteAbortedException ;
import org.eclipse.jgit.util.BlockList ;
import org.eclipse.jgit.util.BlockList ;
@ -303,7 +305,7 @@ public class PackWriter implements AutoCloseable {
private ObjectCountCallback callback ;
private ObjectCountCallback callback ;
private long filterBlobLimit = - 1 ;
private FilterSpec filterSpec = FilterSpec . NO_FILTER ;
/ * *
/ * *
* Create writer for specified repository .
* Create writer for specified repository .
@ -641,10 +643,11 @@ public class PackWriter implements AutoCloseable {
}
}
/ * *
/ * *
* @param bytes exclude blobs of size greater than this
* @param filter the filter which indicates what and what not this writer
* should include
* /
* /
public void setFilterBlobLimit ( long bytes ) {
public void setFilterSpec ( @NonNull FilterSpec filter ) {
filterBlobLimit = bytes ;
filterSpec = requireNonNull ( filter ) ;
}
}
/ * *
/ * *
@ -2079,10 +2082,10 @@ public class PackWriter implements AutoCloseable {
// Check if this object needs to be rejected, doing the cheaper
// Check if this object needs to be rejected, doing the cheaper
// checks first.
// checks first.
boolean reject = filterBlobLimit > = 0 & &
boolean reject = filterSpec . get BlobLimit ( ) > = 0 & &
type = = OBJ_BLOB & &
type = = OBJ_BLOB & &
! want . contains ( src ) & &
! want . contains ( src ) & &
reader . getObjectSize ( src , OBJ_BLOB ) > filterBlobLimit ;
reader . getObjectSize ( src , OBJ_BLOB ) > filterSpec . get BlobLimit ( ) ;
if ( ! reject ) {
if ( ! reject ) {
addObject ( src , type , pathHashCode ) ;
addObject ( src , type , pathHashCode ) ;
}
}