]> source.dussan.org Git - jgit.git/commitdiff
Skip first pack if avoid garbage is set and it is a garbage pack 89/90989/5
authorZhen Chen <czhen@google.com>
Mon, 13 Feb 2017 20:36:25 +0000 (12:36 -0800)
committerZhen Chen <czhen@google.com>
Tue, 14 Feb 2017 00:54:35 +0000 (20:54 -0400)
At beginning of the OBJECT_SCAN loop, it will first check if the object
exists in the last pack, however, it forgot to avoid garbage pack for
the first iteration.

Change-Id: I8a99c0f439218d19c49cd4dae891b8cc4a57099d
Signed-off-by: Zhen Chen <czhen@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsReader.java

index 8d934879e10a42ebd5b14adb3a339aa63a6a1e83..3593c6101c1d6a1acb931d276abaa50faa5ec5f4 100644 (file)
@@ -332,15 +332,17 @@ public final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
 
                OBJECT_SCAN: for (Iterator<T> it = pending.iterator(); it.hasNext();) {
                        T t = it.next();
-                       try {
-                               long p = lastPack.findOffset(this, t);
-                               if (0 < p) {
-                                       r.add(new FoundObject<T>(t, lastIdx, lastPack, p));
-                                       it.remove();
-                                       continue;
+                       if (!skipGarbagePack(lastPack)) {
+                               try {
+                                       long p = lastPack.findOffset(this, t);
+                                       if (0 < p) {
+                                               r.add(new FoundObject<T>(t, lastIdx, lastPack, p));
+                                               it.remove();
+                                               continue;
+                                       }
+                               } catch (IOException e) {
+                                       // Fall though and try to examine other packs.
                                }
-                       } catch (IOException e) {
-                               // Fall though and try to examine other packs.
                        }
 
                        for (int i = 0; i < packs.length; i++) {