[JGIT PATCH 03/21] Use PackedObjectInfo as a base class for PackWriter's ObjectToPack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The ObjectId and offset portions of PackedObjectInfo are also
needed by ObjectToPack.  By sharing the same base class with
IndexPack we can later abstract the index writing function out
and use it inside of both IndexPack and PackWriter.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../src/org/spearce/jgit/lib/PackWriter.java       |   28 +++-----------------
 1 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
index cec2ab0..ccc6cfe 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
@@ -56,6 +56,7 @@ import org.spearce.jgit.revwalk.ObjectWalk;
 import org.spearce.jgit.revwalk.RevFlag;
 import org.spearce.jgit.revwalk.RevObject;
 import org.spearce.jgit.revwalk.RevSort;
+import org.spearce.jgit.transport.PackedObjectInfo;
 import org.spearce.jgit.util.CountingOutputStream;
 import org.spearce.jgit.util.NB;
 
@@ -617,7 +618,7 @@ public class PackWriter {
 
 		assert !otp.isWritten();
 
-		otp.markWritten(countingOut.getCount());
+		otp.setOffset(countingOut.getCount());
 		if (otp.isDeltaRepresentation())
 			writeDeltaObject(otp);
 		else
@@ -762,13 +763,11 @@ public class PackWriter {
 	 * pack-file and object status.
 	 *
 	 */
-	static class ObjectToPack extends ObjectId {
+	static class ObjectToPack extends PackedObjectInfo {
 		private ObjectId deltaBase;
 
 		private PackedObjectLoader reuseLoader;
 
-		private long offset = -1;
-
 		private int deltaDepth;
 
 		private boolean wantWrite;
@@ -838,26 +837,7 @@ public class PackWriter {
 		 * @return true if object is already written; false otherwise.
 		 */
 		boolean isWritten() {
-			return offset != -1;
-		}
-
-		/**
-		 * @return offset in pack when object has been already written, or -1 if
-		 *         it has not been written yet
-		 */
-		long getOffset() {
-			return offset;
-		}
-
-		/**
-		 * Mark object as written. This information is used to achieve
-		 * delta-base precedence in a pack file.
-		 *
-		 * @param offset
-		 *            offset where written object starts
-		 */
-		void markWritten(long offset) {
-			this.offset = offset;
+			return getOffset() != 0;
 		}
 
 		PackedObjectLoader getReuseLoader() {
-- 
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux