Merge "PackBitmapIndex: clarify naming of getObject inputs"
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java
index 4c3f6c1..cbda8fc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndex.java
@@ -154,7 +154,9 @@
 	 * Get the object at the bitmap position.
 	 *
 	 * @param position
-	 *            the id for which the object will be found.
+	 *            the offset in the bitmap which corresponds to an object of
+	 *            interest. This position is the same as the order of the object
+	 *            in the {@link PackFile}.
 	 * @return the ObjectId.
 	 * @throws java.lang.IllegalArgumentException
 	 *             when the item is not found.
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
index 03d6948..7646c19 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexBuilder.java
@@ -106,7 +106,7 @@
 				.signum(a.getOffset() - b.getOffset()));
 		for (int i = 0; i < entries.size(); i++) {
 			PositionEntry e = positionEntries.get(entries.get(i));
-			e.offsetPosition = i;
+			e.ridxPosition = i;
 			byOffset.add(e);
 		}
 	}
@@ -191,7 +191,7 @@
 			throw new IllegalStateException();
 		}
 		bestBitmap.trim();
-		StoredEntry result = new StoredEntry(entry.namePosition, bestBitmap,
+		StoredEntry result = new StoredEntry(entry.idxPosition, bestBitmap,
 				bestXorOffset, bitmapToWrite.getFlags());
 
 		return result;
@@ -235,7 +235,7 @@
 		PositionEntry entry = positionEntries.get(objectId);
 		if (entry == null)
 			return -1;
-		return entry.offsetPosition;
+		return entry.ridxPosition;
 	}
 
 	@Override
@@ -330,16 +330,20 @@
 
 	/** Data object for the on disk representation of a bitmap entry. */
 	public static final class StoredEntry {
-		private final long objectId;
+		private final long idxPosition;
+
 		private final EWAHCompressedBitmap bitmap;
+
 		private final int xorOffset;
+
 		private final int flags;
 
 		/**
 		 * Create a StoredEntry
 		 *
-		 * @param objectId
-		 *            offset of this object into the pack index
+		 * @param idxPosition
+		 *            position of this object into the pack index (i.e. sorted
+		 *            by sha1)
 		 * @param bitmap
 		 *            bitmap associated with this object
 		 * @param xorOffset
@@ -349,9 +353,9 @@
 		 * @param flags
 		 *            flags for this bitmap
 		 */
-		public StoredEntry(long objectId, EWAHCompressedBitmap bitmap,
+		public StoredEntry(long idxPosition, EWAHCompressedBitmap bitmap,
 				int xorOffset, int flags) {
-			this.objectId = objectId;
+			this.idxPosition = idxPosition;
 			this.bitmap = bitmap;
 			this.xorOffset = xorOffset;
 			this.flags = flags;
@@ -385,23 +389,22 @@
 		}
 
 		/**
-		 * Get the ObjectId
-		 *
-		 * @return the ObjectId
+		 * @return the position of the object with this bitmap in the primary
+		 *         index (i.e. ordered by sha1)
 		 */
-		public long getObjectId() {
-			return objectId;
+		public long getIdxPosition() {
+			return idxPosition;
 		}
 	}
 
 	private static final class PositionEntry extends ObjectIdOwnerMap.Entry {
-		final int namePosition;
+		final int idxPosition;
 
-		int offsetPosition;
+		int ridxPosition;
 
-		PositionEntry(AnyObjectId objectId, int namePosition) {
+		PositionEntry(AnyObjectId objectId, int idxPosition) {
 			super(objectId);
-			this.namePosition = namePosition;
+			this.idxPosition = idxPosition;
 		}
 	}
 }
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java
index 84326d5..38d7c90 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/PackBitmapIndexWriterV1.java
@@ -115,7 +115,7 @@
 
 	private void writeBitmapEntry(StoredEntry entry) throws IOException {
 		// Write object, XOR offset, and bitmap
-		dataOutput.writeInt((int) entry.getObjectId());
+		dataOutput.writeInt((int) entry.getIdxPosition());
 		out.write(entry.getXorOffset());
 		out.write(entry.getFlags());
 		writeBitmap(entry.getBitmap());