diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java index 184a9c1dd..a8c8aaebc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/BitmapIndexImpl.java @@ -119,10 +119,10 @@ public class BitmapIndexImpl implements BitmapIndex { return position; } - int addObject(AnyObjectId objectId, int type) { + int findOrInsert(AnyObjectId objectId, int type) { int position = findPosition(objectId); if (position < 0) { - position = mutableIndex.addObject(objectId, type); + position = mutableIndex.findOrInsert(objectId, type); position += indexObjectCount; } return position; @@ -215,7 +215,7 @@ public class BitmapIndexImpl implements BitmapIndex { @Override public boolean add(AnyObjectId objectId, int type) { - int position = addObject(objectId, type); + int position = findOrInsert(objectId, type); if (bitset.contains(position)) return false; @@ -235,6 +235,12 @@ public class BitmapIndexImpl implements BitmapIndex { return 0 <= position && bitset.contains(position); } + @Override + public BitmapBuilder addObject(AnyObjectId objectId, int type) { + bitset.set(findOrInsert(objectId, type)); + return this; + } + @Override public void remove(AnyObjectId objectId) { int position = findPosition(objectId); @@ -446,7 +452,7 @@ public class BitmapIndexImpl implements BitmapIndex { } } - int addObject(AnyObjectId objectId, int type) { + int findOrInsert(AnyObjectId objectId, int type) { MutableEntry entry = new MutableEntry( objectId, type, revList.size()); revList.add(entry); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java index 3c0e2c128..a4b4b6ef2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BitmapIndex.java @@ -125,7 +125,9 @@ public interface BitmapIndex { * @param type * the Git object type. See {@link Constants}. * @return true if the value was not contained or able to be loaded. + * @deprecated use {@link #or} or {@link #addObject} instead. */ + @Deprecated boolean add(AnyObjectId objectId, int type); /** @@ -137,6 +139,18 @@ public interface BitmapIndex { */ boolean contains(AnyObjectId objectId); + /** + * Adds the id to the bitmap. + * + * @param objectId + * the object ID + * @param type + * the Git object type. See {@link Constants}. + * @return the current builder. + * @since 4.2 + */ + BitmapBuilder addObject(AnyObjectId objectId, int type); + /** * Remove the id from the bitmap. *