PackWriter calls this getOffset() and hides the field as a private field as part of its related ObjectToPack class. We do that here as part of ObjectEntry's API so we can later replace that part of ObjectToPack by inheriting from ObjectEntry. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- .../src/org/spearce/jgit/transport/IndexPack.java | 11 ++++++----- .../org/spearce/jgit/transport/ObjectEntry.java | 12 ++++++++++-- 2 files changed, 16 insertions(+), 7 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 e182cfc..19a4b7b 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/IndexPack.java @@ -281,8 +281,9 @@ public class IndexPack { } private void resolveDeltas(final ObjectEntry oe) throws IOException { - if (baseById.containsKey(oe) || baseByPos.containsKey(new Long(oe.pos))) - resolveDeltas(oe.pos, Constants.OBJ_BAD, null, oe); + if (baseById.containsKey(oe) + || baseByPos.containsKey(new Long(oe.getOffset()))) + resolveDeltas(oe.getOffset(), Constants.OBJ_BAD, null, oe); } private void resolveDeltas(final long pos, int type, byte[] data, @@ -381,7 +382,7 @@ public class IndexPack { writeWhole(def, typeCode, data); end = packOut.getFilePointer(); - resolveChildDeltas(oe.pos, typeCode, data, oe); + resolveChildDeltas(oe.getOffset(), typeCode, data, oe); if (progress.isCancelled()) throw new IOException("Download cancelled during indexing"); } @@ -458,9 +459,9 @@ public class IndexPack { } for (int i = 0; i < entryCount; i++) { final ObjectEntry oe = entries[i]; - if (oe.pos >>> 1 > Integer.MAX_VALUE) + if (oe.getOffset() >>> 1 > Integer.MAX_VALUE) throw new IOException("Pack too large for index version 1"); - NB.encodeInt32(rawoe, 0, (int) oe.pos); + NB.encodeInt32(rawoe, 0, (int) oe.getOffset()); oe.copyRawTo(rawoe, 4); os.write(rawoe); d.update(rawoe); diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ObjectEntry.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ObjectEntry.java index 58d2eb2..10a8f4d 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/transport/ObjectEntry.java +++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ObjectEntry.java @@ -42,10 +42,18 @@ import org.spearce.jgit.lib.AnyObjectId; import org.spearce.jgit.lib.ObjectId; class ObjectEntry extends ObjectId { - final long pos; + private long offset; ObjectEntry(final long headerOffset, final AnyObjectId id) { super(id); - pos = headerOffset; + offset = headerOffset; + } + + /** + * @return offset in pack when object has been already written, or -1 if it + * has not been written yet + */ + long getOffset() { + return offset; } } -- 1.5.6.74.g8a5e -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html