git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 1/8] Correct thin pack completion in IndexPack to handle some bundles

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 1, 2008, 03:03 UTC
Message-ID
<1214881445-3931-2-git-send-email-spearce@spearce.org>
In-Reply-To
<1214881445-3931-1-git-send-email-spearce@spearce.org>

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@spearce.org>
---
 .../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
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 2 of 9 in “Minor push fixups”
  1. 0/8 Minor push fixupsShawn O. Pearce, Jul 1, 2008
  2. 1/8 Correct thin pack completion in IndexPack to handle some bundlesShawn O. Pearce, Jul 1, 2008
  3. 2/8 Delete reflog when deleting ref during dumb transport pushShawn O. Pearce, Jul 1, 2008
  4. 3/8 Refuse to create or delete funny ref names over dumb transportsShawn O. Pearce, Jul 1, 2008
  5. 4/8 Shorten progress message text from PackWriterShawn O. Pearce, Jul 1, 2008
  6. 5/8 Correctly name the stderr redirection thread for local transportShawn O. Pearce, Jul 1, 2008
  7. 6/8 Support 'git upload-pack' and 'git receive-pack' over SSHShawn O. Pearce, Jul 1, 2008
  8. 7/8 Pack jgit into a portable single file command line utilityShawn O. Pearce, Jul 1, 2008
  9. 8/8 Don't try to pack 0{40} during push of delete and updateShawn O. Pearce, Jul 1, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.