From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
Marek Zawirski <marek.zawirski@gmail.com>
Cc: git@vger.kernel.org, "Shawn O. Pearce" <spearce@spearce.org>
Subject: [JGIT PATCH 02/10] Make ObjectEntry's position field private
Date: Mon, 23 Jun 2008 22:10:00 -0400 [thread overview]
Message-ID: <1214273408-70793-3-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1214273408-70793-2-git-send-email-spearce@spearce.org>
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@spearce.org>
---
.../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
next prev parent reply other threads:[~2008-06-24 2:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-24 2:09 [JGIT PATCH 00/10] Support writing pack index version 2 Shawn O. Pearce
2008-06-24 2:09 ` [JGIT PATCH 01/10] Extract inner ObjectEntry from IndexPack class Shawn O. Pearce
2008-06-24 2:10 ` Shawn O. Pearce [this message]
2008-06-24 2:10 ` [JGIT PATCH 03/10] Rename ObjectEntry to PackedObjectInfo Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 04/10] Document PackedObjectInfo and make it public for reuse Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 05/10] Refactor pack index writing to a common API Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 06/10] Reuse the magic tOc constant for pack index headers Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 07/10] Add 64 bit network byte order encoding to NB Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 08/10] Compute packed object entry CRC32 data during IndexPack Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 09/10] Add support for writing pack index v2 files Shawn O. Pearce
2008-06-24 2:10 ` [JGIT PATCH 10/10] Default IndexPack to honor pack.indexversion configuration Shawn O. Pearce
2008-06-25 4:01 ` [JGIT PATCH 06/10 v2] Reuse the magic tOc constant for pack index headers Shawn O. Pearce
2008-06-24 22:48 ` [JGIT PATCH 00/10] Support writing pack index version 2 Robin Rosenberg
2008-06-25 3:54 ` Shawn O. Pearce
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=1214273408-70793-3-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--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).