Browse Source

Only throw MissingObjectException when necessary

When preparing the bitmap, the flag ignoreMissingStart only applied to
the start object. However, sometime the start object is present but some
related objects are not present during the walk, we should only release
the MissingObjectException when the ignoreMissingStart is set false.

Change-Id: I1097a2defa4a9dcf502ca8baca5d32880378818f
Signed-off-by: Zhen Chen <czhen@google.com>
stable-4.8
Zhen Chen 8 years ago committed by Jonathan Nieder
parent
commit
f5368dc97f
  1. 49
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java

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

@ -117,24 +117,39 @@ final class PackWriterBitmapWalker {
new AddUnseenToBitmapFilter(seen, bitmapResult)); new AddUnseenToBitmapFilter(seen, bitmapResult));
} }
while (walker.next() != null) { try {
// Iterate through all of the commits. The BitmapRevFilter does while (walker.next() != null) {
// the work. // Iterate through all of the commits. The BitmapRevFilter does
// // the work.
// filter.include returns true for commits that do not have //
// a bitmap in bitmapIndex and are not reachable from a // filter.include returns true for commits that do not have
// bitmap in bitmapIndex encountered earlier in the walk. // a bitmap in bitmapIndex and are not reachable from a
// Thus the number of commits returned by next() measures how // bitmap in bitmapIndex encountered earlier in the walk.
// much history was traversed without being able to make use // Thus the number of commits returned by next() measures how
// of bitmaps. // much history was traversed without being able to make use
pm.update(1); // of bitmaps.
countOfBitmapIndexMisses++; pm.update(1);
} countOfBitmapIndexMisses++;
}
RevObject ro; RevObject ro;
while ((ro = walker.nextObject()) != null) { while ((ro = walker.nextObject()) != null) {
bitmapResult.addObject(ro, ro.getType()); bitmapResult.addObject(ro, ro.getType());
pm.update(1); pm.update(1);
}
} catch (MissingObjectException e) {
if (!ignoreMissingStart) {
throw e;
}
// Even when none of the objects we started the walk from is missing,
// an object reachable from one can be. RevWalk and ObjectWalk don't
// provide a way to ignore the missing object and continue, so bail
// out early with an undersized bitmap.
//
// The resulting packfile is likely to be much too large, but that's
// better than serving an error.
//
// TODO(czhen): Resume the walk instead once RevWalk supports that.
} }
} }

Loading…
Cancel
Save