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

[JGIT Test Case] This (incomplete) test case demo the index wrong CRC bug.

From
Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com>
Date
Mar 24, 2009, 11:13 UTC
Message-ID
<1237893210-23073-1-git-send-email-j16sdiz+freenet@gmail.com>
In-Reply-To
<ff6a9c820903231953q29a5ccbk8e5b54c9afdb8abd@mail.gmail.com>

The PackIndex always give 0 for CRC. I know this patch is ugly, but I am not familiar with the code to make a good test code.

Signed-off-by: Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com>
---
 .../tst/org/spearce/jgit/lib/PackWriterTest.java   |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
index f7139fc..0279c6b 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
@@ -40,6 +40,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -354,6 +355,19 @@ public void testWritePack4SizeThinVsNoThin() throws Exception {
 		assertTrue(sizePack4 > sizePack4Thin);
 	}
 
+	public void testWriteIndex() throws Exception {
+		testWritePack4();
+
+		File idxFile = File.createTempFile("temp", ".idx");
+		FileOutputStream ios = new FileOutputStream(idxFile);
+		writer.writeIndex(ios);
+		ios.close();
+
+		PackIndex idx = PackIndex.open(idxFile);
+		assertFalse(0 == idx.findCRC32(ObjectId
+				.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7")));
+	}
+
 	// TODO: testWritePackDeltasCycle()
 	// TODO: testWritePackDeltasDepth()
 
-- 
1.6.2
Previous: Daniel ChengNext: Daniel Cheng (aka SDiZ)
Message 2 of 7 in “[JGit] Mismatch CRC in packed objects from `jgit push`”
  1. Daniel ChengMar 24, 2009
  2. [JGIT Test Case] This (incomplete) test case demo the index wrong CRC bug.Daniel Cheng (aka SDiZ), Mar 24, 2009
  3. 1/2 Calculate CRC32 on Pack Index v2Daniel Cheng (aka SDiZ), Mar 25, 2009
  4. 2/2 Test case for pack index CRCDaniel Cheng (aka SDiZ), Mar 25, 2009
  5. Marek ZawirskiMar 25, 2009
  6. Shawn O. PearceMar 25, 2009
  7. Daniel ChengMar 26, 2009

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.