diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2011-08-10 14:39:30 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2011-08-10 14:39:30 -0400 |
commit | d4db26bb57b0a8027764679e06a99d3f4bfe628e (patch) | |
tree | 5ce2a35b629c03b30b0661e726208d598574df52 /org.eclipse.jgit | |
parent | 8db5b6a013d9cb076b2cb7122f111bbac317f3f2 (diff) | |
parent | 3bac5b1d7d85aba3ec4aea0286eabbc8b326208b (diff) | |
download | jgit-d4db26bb57b0a8027764679e06a99d3f4bfe628e.tar.gz jgit-d4db26bb57b0a8027764679e06a99d3f4bfe628e.zip |
Merge "Fix offset64 creation for objects at 2 GiB"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackIndexWriterV2.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackIndexWriterV2.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackIndexWriterV2.java index 21ebd1ca9c..7671cd6f1c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackIndexWriterV2.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackIndexWriterV2.java @@ -56,6 +56,9 @@ import org.eclipse.jgit.util.NB; * @see PackIndexV2 */ class PackIndexWriterV2 extends PackIndexWriter { + private static final int MAX_OFFSET_32 = 0x7fffffff; + private static final int IS_OFFSET_64 = 0x80000000; + PackIndexWriterV2(final OutputStream dst) { super(dst); } @@ -87,10 +90,10 @@ class PackIndexWriterV2 extends PackIndexWriter { int o64 = 0; for (final PackedObjectInfo oe : entries) { final long o = oe.getOffset(); - if (o < Integer.MAX_VALUE) + if (o <= MAX_OFFSET_32) NB.encodeInt32(tmp, 0, (int) o); else - NB.encodeInt32(tmp, 0, (1 << 31) | o64++); + NB.encodeInt32(tmp, 0, IS_OFFSET_64 | o64++); out.write(tmp, 0, 4); } } @@ -98,7 +101,7 @@ class PackIndexWriterV2 extends PackIndexWriter { private void writeOffset64() throws IOException { for (final PackedObjectInfo oe : entries) { final long o = oe.getOffset(); - if (o > Integer.MAX_VALUE) { + if (MAX_OFFSET_32 < o) { NB.encodeInt64(tmp, 0, o); out.write(tmp, 0, 8); } |