diff options
author | Zhen Chen <czhen@google.com> | 2017-03-29 22:47:23 -0700 |
---|---|---|
committer | Jonathan Nieder <jrn@google.com> | 2017-04-05 19:09:16 -0400 |
commit | f5368dc97f564cf5eac3e7e2742680bf2f95fc0b (patch) | |
tree | 71c94993f5a52407f47e3a5d0b39413e9ca67111 /org.eclipse.jgit | |
parent | f32d65759c9afdcbec28eb3051ed9138b8e03271 (diff) | |
download | jgit-f5368dc97f564cf5eac3e7e2742680bf2f95fc0b.tar.gz jgit-f5368dc97f564cf5eac3e7e2742680bf2f95fc0b.zip |
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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java index 2ec4d568c7..7e3e189be7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/PackWriterBitmapWalker.java @@ -117,24 +117,39 @@ final class PackWriterBitmapWalker { new AddUnseenToBitmapFilter(seen, bitmapResult)); } - while (walker.next() != null) { - // 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 - // bitmap in bitmapIndex encountered earlier in the walk. - // Thus the number of commits returned by next() measures how - // much history was traversed without being able to make use - // of bitmaps. - pm.update(1); - countOfBitmapIndexMisses++; - } + try { + while (walker.next() != null) { + // 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 + // bitmap in bitmapIndex encountered earlier in the walk. + // Thus the number of commits returned by next() measures how + // much history was traversed without being able to make use + // of bitmaps. + pm.update(1); + countOfBitmapIndexMisses++; + } - RevObject ro; - while ((ro = walker.nextObject()) != null) { - bitmapResult.addObject(ro, ro.getType()); - pm.update(1); + RevObject ro; + while ((ro = walker.nextObject()) != null) { + bitmapResult.addObject(ro, ro.getType()); + 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. } } |