From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: Marek Zawirski <marek.zawirski@gmail.com>,
Daniel Cheng <j16sdiz+freenet@gmail.com>,
git@vger.kernel.org
Subject: [JGIT PATCH 3/5] Test case for pack index CRC32 when written by PackWriter
Date: Wed, 25 Mar 2009 18:21:53 -0700 [thread overview]
Message-ID: <1238030515-31768-3-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1238030515-31768-2-git-send-email-spearce@spearce.org>
Suggested-by: Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../tst/org/spearce/jgit/lib/PackWriterTest.java | 33 ++++++++++++++++++++
1 files changed, 33 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 46616e3..636059f 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;
@@ -353,6 +354,37 @@ public void testWritePack4SizeThinVsNoThin() throws Exception {
assertTrue(sizePack4 > sizePack4Thin);
}
+ public void testWriteIndex() throws Exception {
+ writer.setIndexVersion(2);
+ writeVerifyPack4(false);
+
+ // Validate that IndexPack came up with the right CRC32 value.
+ final PackIndex idx1 = PackIndex.open(indexFile);
+ assertTrue(idx1 instanceof PackIndexV2);
+ assertEquals(0x4743F1E4L, idx1.findCRC32(ObjectId
+ .fromString("82c6b885ff600be425b4ea96dee75dca255b69e7")));
+
+ // Validate that an index written by PackWriter is the same.
+ final File idx2File = new File(indexFile.getAbsolutePath() + ".2");
+ final FileOutputStream is = new FileOutputStream(idx2File);
+ try {
+ writer.writeIndex(is);
+ } finally {
+ is.close();
+ }
+ final PackIndex idx2 = PackIndex.open(idx2File);
+ assertTrue(idx2 instanceof PackIndexV2);
+ assertEquals(idx1.getObjectCount(), idx2.getObjectCount());
+ assertEquals(idx1.getOffset64Count(), idx2.getOffset64Count());
+
+ for (int i = 0; i < idx1.getObjectCount(); i++) {
+ final ObjectId id = idx1.getObjectId(i);
+ assertEquals(id, idx2.getObjectId(i));
+ assertEquals(idx1.findOffset(id), idx2.findOffset(id));
+ assertEquals(idx1.findCRC32(id), idx2.findCRC32(id));
+ }
+ }
+
// TODO: testWritePackDeltasCycle()
// TODO: testWritePackDeltasDepth()
@@ -469,6 +501,7 @@ private void verifyOpenPack(final boolean thin) throws IOException {
final IndexPack indexer = new IndexPack(db, is, packBase);
indexer.setKeepEmpty(true);
indexer.setFixThin(thin);
+ indexer.setIndexVersion(2);
indexer.index(new TextProgressMonitor());
pack = new PackFile(indexFile, packFile);
}
--
1.6.2.1.471.g682837
next prev parent reply other threads:[~2009-03-26 1:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-26 1:21 [JGIT PATCH 1/5] Remove dead/unused reset method from CountingOutputStream Shawn O. Pearce
2009-03-26 1:21 ` [JGIT PATCH 2/5] Implement CRC32 computation during PackWriter Shawn O. Pearce
2009-03-26 1:21 ` Shawn O. Pearce [this message]
2009-03-26 1:21 ` [JGIT PATCH 4/5] Write the pack header in one shot Shawn O. Pearce
2009-03-26 1:21 ` [JGIT PATCH 5/5] Use Deflater directly in PackWriter Shawn O. Pearce
2009-03-26 15:35 ` [JGIT PATCH 3/5] Test case for pack index CRC32 when written by PackWriter Daniel Cheng
2009-03-26 15:35 ` Daniel Cheng
2009-03-27 8:11 ` patch series starting with [JGIT PATCH 1/5] Remove dead/unused reset method from CountingOutputStream Robin Rosenberg
2009-03-27 14:51 ` Shawn O. Pearce
2009-03-27 14:55 ` Shawn O. Pearce
2009-03-27 23:53 ` Robin Rosenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1238030515-31768-3-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=j16sdiz+freenet@gmail.com \
--cc=marek.zawirski@gmail.com \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).