@ -80,6 +80,7 @@ import java.util.zip.CheckedOutputStream;
import java.util.zip.Deflater ;
import java.util.zip.DeflaterOutputStream ;
import org.eclipse.jgit.annotations.NonNull ;
import org.eclipse.jgit.errors.CorruptObjectException ;
import org.eclipse.jgit.errors.IncorrectObjectTypeException ;
import org.eclipse.jgit.errors.LargeObjectException ;
@ -162,6 +163,9 @@ import org.eclipse.jgit.util.TemporaryBuffer;
public class PackWriter implements AutoCloseable {
private static final int PACK_VERSION_GENERATED = 2 ;
/** Empty set of objects for {@code preparePack()}. */
public static Set < ObjectId > NONE = Collections . emptySet ( ) ;
private static final Map < WeakReference < PackWriter > , Boolean > instances =
new ConcurrentHashMap < WeakReference < PackWriter > , Boolean > ( ) ;
@ -670,7 +674,7 @@ public class PackWriter implements AutoCloseable {
* @throws IOException
* when some I / O problem occur during reading objects .
* /
public void preparePack ( fina l Iterator < RevObject > objectsSource )
public void preparePack ( @NonNul l Iterator < RevObject > objectsSource )
throws IOException {
while ( objectsSource . hasNext ( ) ) {
addObject ( objectsSource . next ( ) ) ;
@ -693,16 +697,18 @@ public class PackWriter implements AutoCloseable {
* progress during object enumeration .
* @param want
* collection of objects to be marked as interesting ( start
* points of graph traversal ) .
* points of graph traversal ) . Must not be { @code null } .
* @param have
* collection of objects to be marked as uninteresting ( end
* points of graph traversal ) .
* points of graph traversal ) . Pass { @link # NONE } if all objects
* reachable from { @code want } are desired , such as when serving
* a clone .
* @throws IOException
* when some I / O problem occur during reading objects .
* /
public void preparePack ( ProgressMonitor countingMonitor ,
Set < ? extends ObjectId > want ,
Set < ? extends ObjectId > have ) throws IOException {
@NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > have ) throws IOException {
ObjectWalk ow ;
if ( shallowPack )
ow = new DepthWalk . ObjectWalk ( reader , depth ) ;
@ -729,17 +735,19 @@ public class PackWriter implements AutoCloseable {
* ObjectWalk to perform enumeration .
* @param interestingObjects
* collection of objects to be marked as interesting ( start
* points of graph traversal ) .
* points of graph traversal ) . Must not be { @code null } .
* @param uninterestingObjects
* collection of objects to be marked as uninteresting ( end
* points of graph traversal ) .
* points of graph traversal ) . Pass { @link # NONE } if all objects
* reachable from { @code want } are desired , such as when serving
* a clone .
* @throws IOException
* when some I / O problem occur during reading objects .
* /
public void preparePack ( ProgressMonitor countingMonitor ,
ObjectWalk walk ,
fina l Set < ? extends ObjectId > interestingObjects ,
fina l Set < ? extends ObjectId > uninterestingObjects )
@NonNull ObjectWalk walk ,
@NonNul l Set < ? extends ObjectId > interestingObjects ,
@NonNul l Set < ? extends ObjectId > uninterestingObjects )
throws IOException {
if ( countingMonitor = = null )
countingMonitor = NullProgressMonitor . INSTANCE ;
@ -1597,17 +1605,12 @@ public class PackWriter implements AutoCloseable {
out . write ( packcsum ) ;
}
private void findObjectsToPack ( final ProgressMonitor countingMonitor ,
final ObjectWalk walker , final Set < ? extends ObjectId > want ,
Set < ? extends ObjectId > have )
throws MissingObjectException , IOException ,
IncorrectObjectTypeException {
private void findObjectsToPack ( @NonNull ProgressMonitor countingMonitor ,
@NonNull ObjectWalk walker , @NonNull Set < ? extends ObjectId > want ,
@NonNull Set < ? extends ObjectId > have ) throws IOException {
final long countingStart = System . currentTimeMillis ( ) ;
beginPhase ( PackingPhase . COUNTING , countingMonitor , ProgressMonitor . UNKNOWN ) ;
if ( have = = null )
have = Collections . emptySet ( ) ;
stats . interestingObjects = Collections . unmodifiableSet ( new HashSet < ObjectId > ( want ) ) ;
stats . uninterestingObjects = Collections . unmodifiableSet ( new HashSet < ObjectId > ( have ) ) ;