From 3069f994016cd651c90cce8f4d4f0ecad94218b8 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 24 Dec 2008 18:11:14 -0800 Subject: [PATCH] Correctly use a long for the offsets within a generated pack Pack files can be larger than 2 GiB, especially if the PackIndexV2 format is being used. Signed-off-by: Shawn O. Pearce Signed-off-by: Robin Rosenberg --- .../tst/org/spearce/jgit/lib/PackWriterTest.java | 12 ++++++------ .../src/org/spearce/jgit/util/CountingOutputStream.java | 5 ++--- 2 files changed, 8 insertions(+), 9 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 ec138a0e..98e0d3af 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 @@ -308,11 +308,11 @@ public class PackWriterTest extends RepositoryTestCase { */ public void testWritePack2SizeDeltasVsNoDeltas() throws Exception { testWritePack2(); - final int sizePack2NoDeltas = cos.getCount(); + final long sizePack2NoDeltas = cos.getCount(); tearDown(); setUp(); testWritePack2DeltasReuseRefs(); - final int sizePack2DeltasRefs = cos.getCount(); + final long sizePack2DeltasRefs = cos.getCount(); assertTrue(sizePack2NoDeltas > sizePack2DeltasRefs); } @@ -327,11 +327,11 @@ public class PackWriterTest extends RepositoryTestCase { */ public void testWritePack2SizeOffsetsVsRefs() throws Exception { testWritePack2DeltasReuseRefs(); - final int sizePack2DeltasRefs = cos.getCount(); + final long sizePack2DeltasRefs = cos.getCount(); tearDown(); setUp(); testWritePack2DeltasReuseOffsets(); - final int sizePack2DeltasOffsets = cos.getCount(); + final long sizePack2DeltasOffsets = cos.getCount(); assertTrue(sizePack2DeltasRefs > sizePack2DeltasOffsets); } @@ -345,11 +345,11 @@ public class PackWriterTest extends RepositoryTestCase { */ public void testWritePack4SizeThinVsNoThin() throws Exception { testWritePack4(); - final int sizePack4 = cos.getCount(); + final long sizePack4 = cos.getCount(); tearDown(); setUp(); testWritePack4ThinPack(); - final int sizePack4Thin = cos.getCount(); + final long sizePack4Thin = cos.getCount(); assertTrue(sizePack4 > sizePack4Thin); } diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java b/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java index 53935dc7..b0b5f7dc 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java +++ b/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java @@ -45,8 +45,7 @@ import java.io.OutputStream; * Counting output stream decoration. Counts bytes written to stream. */ public class CountingOutputStream extends FilterOutputStream { - - private int count; + private long count; /** * Create counting stream being decorated to provided real output stream. @@ -76,7 +75,7 @@ public class CountingOutputStream extends FilterOutputStream { * @return number of written bytes since last reset (object is reset upon * creation) */ - public int getCount() { + public long getCount() { return count; } -- 2.11.4.GIT