Browse Source

Reset ObjectWalker when it starts a new walk

The ObjectWalker in PackWriterBitmapWalker needs to be reset whenever it
starts a new walk. Move this responsibility from the caller to the
method when the new walk starts.

Change-Id: Ib66003be1b5bdc80f46b9bbbb17d45e616714912
Signed-off-by: Zhen Chen <czhen@google.com>
stable-4.8
Zhen Chen 8 years ago
parent
commit
8f7d0a4fbe
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java
  2. 11
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

7
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriter.java

@ -1874,7 +1874,6 @@ public class PackWriter implements AutoCloseable {
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
BitmapBuilder haveBitmap = bitmapWalker.findObjects(have, null, true);
bitmapWalker.reset();
BitmapBuilder wantBitmap = bitmapWalker.findObjects(want, haveBitmap,
false);
BitmapBuilder needBitmap = wantBitmap.andNot(haveBitmap);
@ -2079,11 +2078,9 @@ public class PackWriter implements AutoCloseable {
PackWriterBitmapWalker walker = bitmapPreparer.newBitmapWalker();
AnyObjectId last = null;
for (PackWriterBitmapPreparer.BitmapCommit cmit : selectedCommits) {
if (cmit.isReuseWalker())
walker.reset();
else
if (!cmit.isReuseWalker()) {
walker = bitmapPreparer.newBitmapWalker();
}
BitmapBuilder bitmap = walker.findObjects(
Collections.singleton(cmit), null, false);

11
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

@ -84,7 +84,8 @@ final class PackWriterBitmapWalker {
return countOfBitmapIndexMisses;
}
BitmapBuilder findObjects(Iterable<? extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissing)
BitmapBuilder findObjects(Iterable<? extends ObjectId> start, BitmapBuilder seen,
boolean ignoreMissing)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
if (!ignoreMissing) {
@ -132,9 +133,11 @@ final class PackWriterBitmapWalker {
return result;
}
private BitmapBuilder findObjectsWalk(Iterable<? extends ObjectId> start, BitmapBuilder seen, boolean ignoreMissingStart)
private BitmapBuilder findObjectsWalk(Iterable<? extends ObjectId> start, BitmapBuilder seen,
boolean ignoreMissingStart)
throws MissingObjectException, IncorrectObjectTypeException,
IOException {
walker.reset();
final BitmapBuilder bitmapResult = bitmapIndex.newBitmapBuilder();
for (ObjectId obj : start) {
@ -189,10 +192,6 @@ final class PackWriterBitmapWalker {
return bitmapResult;
}
void reset() {
walker.reset();
}
/**
* A RevFilter that adds the visited commits to {@code bitmap} as a side
* effect.

Loading…
Cancel
Save