Recently I saw a bundle with a chain of deltas to base objects as A->B->C, where A was the delta depending on the base B. In this pack all of the objects used OBJ_REF_DELTA to link to their base and C was not in the pack (it was assumed to be in the repository). Because of the ordering of the ObjectIds for B and C jgit tried to resolve A's delta base by pulling from the repository, as B was not found in the pack file. The reason B was not found was because it was waiting in the queue (to be processed next) and we did not know what B's ObjectId was. By skipping objects whose ObjectLoader's aren't found we should be able to resolve those objects later when their delta base does get resolved in this pack. However by the end of of this loop we must have no more objects depending on something by ObjectId, as that is an indication that the local repository is missing the objects we must have to complete this thin pack. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/transport/IndexPack.java | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java index 24a0577..29d99db 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java @@ -55,6 +55,7 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; import org.spearce.jgit.errors.CorruptObjectException; +import org.spearce.jgit.errors.MissingObjectException; import org.spearce.jgit.lib.BinaryDelta; import org.spearce.jgit.lib.Constants; import org.spearce.jgit.lib.InflaterCache; @@ -399,9 +400,10 @@ public class IndexPack { final Deflater def = new Deflater(Deflater.DEFAULT_COMPRESSION, false); long end = packOut.length() - 20; - while (!baseById.isEmpty()) { - final ObjectId baseId = baseById.keySet().iterator().next(); + for (final ObjectId baseId : new ArrayList<ObjectId>(baseById.keySet())) { final ObjectLoader ldr = repo.openObject(baseId); + if (ldr == null) + continue; final byte[] data = ldr.getBytes(); final int typeCode = ldr.getType(); final PackedObjectInfo oe; @@ -419,6 +421,11 @@ public class IndexPack { } def.end(); + if (!baseById.isEmpty()) { + final ObjectId need = baseById.keySet().iterator().next(); + throw new MissingObjectException(need, "delta base"); + } + fixHeaderFooter(); } -- 1.5.6.74.g8a5e -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html