aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/BitmappedObjectReachabilityChecker.java (renamed from org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmappedObjectReachabilityChecker.java)8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/BitmappedReachabilityChecker.java (renamed from org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmappedReachabilityChecker.java)11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/PedestrianObjectReachabilityChecker.java (renamed from org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PedestrianObjectReachabilityChecker.java)12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/PedestrianReachabilityChecker.java (renamed from org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PedestrianReachabilityChecker.java)8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java57
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java12
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java8
8 files changed, 102 insertions, 26 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmappedObjectReachabilityChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/BitmappedObjectReachabilityChecker.java
index 89aef7dc41..d8056490aa 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmappedObjectReachabilityChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/BitmappedObjectReachabilityChecker.java
@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-package org.eclipse.jgit.revwalk;
+package org.eclipse.jgit.internal.revwalk;
import java.io.IOException;
import java.util.ArrayList;
@@ -21,12 +21,16 @@ import java.util.stream.Stream;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
+import org.eclipse.jgit.revwalk.BitmapWalker;
+import org.eclipse.jgit.revwalk.ObjectReachabilityChecker;
+import org.eclipse.jgit.revwalk.ObjectWalk;
+import org.eclipse.jgit.revwalk.RevObject;
/**
* Checks if all objects are reachable from certain starting points using
* bitmaps.
*/
-class BitmappedObjectReachabilityChecker
+public class BitmappedObjectReachabilityChecker
implements ObjectReachabilityChecker {
private final ObjectWalk walk;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmappedReachabilityChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/BitmappedReachabilityChecker.java
index 0d9c4593bf..37721ad1ea 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmappedReachabilityChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/BitmappedReachabilityChecker.java
@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-package org.eclipse.jgit.revwalk;
+package org.eclipse.jgit.internal.revwalk;
import java.io.IOException;
import java.util.ArrayList;
@@ -23,12 +23,17 @@ import org.eclipse.jgit.lib.BitmapIndex;
import org.eclipse.jgit.lib.BitmapIndex.Bitmap;
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.revwalk.ReachabilityChecker;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevFlag;
+import org.eclipse.jgit.revwalk.RevSort;
+import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.revwalk.filter.RevFilter;
/**
* Checks the reachability using bitmaps.
*/
-class BitmappedReachabilityChecker implements ReachabilityChecker {
+public class BitmappedReachabilityChecker implements ReachabilityChecker {
private final RevWalk walk;
@@ -42,7 +47,7 @@ class BitmappedReachabilityChecker implements ReachabilityChecker {
* @throws IOException
* if the index or the object reader cannot be opened.
*/
- BitmappedReachabilityChecker(RevWalk walk)
+ public BitmappedReachabilityChecker(RevWalk walk)
throws IOException {
this.walk = walk;
if (walk.getObjectReader().getBitmapIndex() == null) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PedestrianObjectReachabilityChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/PedestrianObjectReachabilityChecker.java
index df5d68a66e..1d1f5fddaf 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PedestrianObjectReachabilityChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/PedestrianObjectReachabilityChecker.java
@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-package org.eclipse.jgit.revwalk;
+package org.eclipse.jgit.internal.revwalk;
import java.io.IOException;
import java.io.InvalidObjectException;
@@ -17,12 +17,18 @@ import java.util.Optional;
import java.util.stream.Stream;
import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.revwalk.ObjectReachabilityChecker;
+import org.eclipse.jgit.revwalk.ObjectWalk;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevObject;
+import org.eclipse.jgit.revwalk.RevSort;
/**
* Checks if all objects are reachable from certain starting points doing a
* walk.
*/
-class PedestrianObjectReachabilityChecker implements ObjectReachabilityChecker {
+public class PedestrianObjectReachabilityChecker
+ implements ObjectReachabilityChecker {
private final ObjectWalk walk;
/**
@@ -31,7 +37,7 @@ class PedestrianObjectReachabilityChecker implements ObjectReachabilityChecker {
* @param walk
* ObjectWalk instance to reuse. Caller retains ownership.
*/
- PedestrianObjectReachabilityChecker(ObjectWalk walk) {
+ public PedestrianObjectReachabilityChecker(ObjectWalk walk) {
this.walk = walk;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PedestrianReachabilityChecker.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/PedestrianReachabilityChecker.java
index 5dc03776c2..a03306b6ee 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/PedestrianReachabilityChecker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/revwalk/PedestrianReachabilityChecker.java
@@ -7,7 +7,7 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-package org.eclipse.jgit.revwalk;
+package org.eclipse.jgit.internal.revwalk;
import java.io.IOException;
import java.util.Collection;
@@ -17,12 +17,16 @@ import java.util.stream.Stream;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.revwalk.ReachabilityChecker;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevSort;
+import org.eclipse.jgit.revwalk.RevWalk;
/**
* Checks the reachability walking the graph from the starters towards the
* target.
*/
-class PedestrianReachabilityChecker implements ReachabilityChecker {
+public class PedestrianReachabilityChecker implements ReachabilityChecker {
private final boolean topoSort;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
index 6bb6ae590a..718ed89142 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java
@@ -17,9 +17,18 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.internal.revwalk.BitmappedObjectReachabilityChecker;
+import org.eclipse.jgit.internal.revwalk.BitmappedReachabilityChecker;
+import org.eclipse.jgit.internal.revwalk.PedestrianObjectReachabilityChecker;
+import org.eclipse.jgit.internal.revwalk.PedestrianReachabilityChecker;
+import org.eclipse.jgit.revwalk.ObjectReachabilityChecker;
+import org.eclipse.jgit.revwalk.ObjectWalk;
+import org.eclipse.jgit.revwalk.ReachabilityChecker;
+import org.eclipse.jgit.revwalk.RevWalk;
/**
* Reads an {@link org.eclipse.jgit.lib.ObjectDatabase} for a single thread.
@@ -408,6 +417,54 @@ public abstract class ObjectReader implements AutoCloseable {
}
/**
+ * Create a reachability checker that will use bitmaps if possible.
+ *
+ * @param rw
+ * revwalk for use by the reachability checker
+ * @return the most efficient reachability checker for this repository.
+ * @throws IOException
+ * if it cannot open any of the underlying indices.
+ *
+ * @since 5.11
+ */
+ @NonNull
+ public ReachabilityChecker createReachabilityChecker(RevWalk rw)
+ throws IOException {
+ if (getBitmapIndex() != null) {
+ return new BitmappedReachabilityChecker(rw);
+ }
+
+ return new PedestrianReachabilityChecker(true, rw);
+ }
+
+ /**
+ * Create an object reachability checker that will use bitmaps if possible.
+ *
+ * This reachability checker accepts any object as target. For checks
+ * exclusively between commits, use
+ * {@link #createReachabilityChecker(RevWalk)}.
+ *
+ * @param ow
+ * objectwalk for use by the reachability checker
+ * @return the most efficient object reachability checker for this
+ * repository.
+ *
+ * @throws IOException
+ * if it cannot open any of the underlying indices.
+ *
+ * @since 5.11
+ */
+ @NonNull
+ public ObjectReachabilityChecker createObjectReachabilityChecker(
+ ObjectWalk ow) throws IOException {
+ if (getBitmapIndex() != null) {
+ return new BitmappedObjectReachabilityChecker(ow);
+ }
+
+ return new PedestrianObjectReachabilityChecker(ow);
+ }
+
+ /**
* Get the {@link org.eclipse.jgit.lib.ObjectInserter} from which this
* reader was created using {@code inserter.newReader()}
*
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
index 4c7a6f556e..e6f9580bf7 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
@@ -172,14 +172,14 @@ public class ObjectWalk extends RevWalk {
* when the index fails to load.
*
* @since 5.8
+ * @deprecated use
+ * {@code ObjectReader#createObjectReachabilityChecker(ObjectWalk)}
+ * instead.
*/
- public ObjectReachabilityChecker createObjectReachabilityChecker()
+ @Deprecated
+ public final ObjectReachabilityChecker createObjectReachabilityChecker()
throws IOException {
- if (reader.getBitmapIndex() != null) {
- return new BitmappedObjectReachabilityChecker(this);
- }
-
- return new PedestrianObjectReachabilityChecker(this);
+ return reader.createObjectReachabilityChecker(this);
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
index 6b62fcdf6d..631d861c0d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
@@ -236,13 +236,13 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* if it cannot open any of the underlying indices.
*
* @since 5.4
+ * @deprecated use {@code ObjectReader#createReachabilityChecker(RevWalk)}
+ * instead.
*/
- public ReachabilityChecker createReachabilityChecker() throws IOException {
- if (reader.getBitmapIndex() != null) {
- return new BitmappedReachabilityChecker(this);
- }
-
- return new PedestrianReachabilityChecker(true, this);
+ @Deprecated
+ public final ReachabilityChecker createReachabilityChecker()
+ throws IOException {
+ return reader.createReachabilityChecker(this);
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
index e0b86f5c11..7f1ddaab2e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java
@@ -1959,8 +1959,8 @@ public class UploadPack {
.map(objId -> objectIdToRevObject(objWalk, objId))
.filter(Objects::nonNull); // Ignore missing tips
- ObjectReachabilityChecker reachabilityChecker = objWalk
- .createObjectReachabilityChecker();
+ ObjectReachabilityChecker reachabilityChecker = reader
+ .createObjectReachabilityChecker(objWalk);
Optional<RevObject> unreachable = reachabilityChecker
.areAllReachable(wantsAsObjs, startersAsObjs);
if (unreachable.isPresent()) {
@@ -1971,8 +1971,8 @@ public class UploadPack {
}
// All wants are commits, we can use ReachabilityChecker
- ReachabilityChecker reachabilityChecker = walk
- .createReachabilityChecker();
+ ReachabilityChecker reachabilityChecker = reader
+ .createReachabilityChecker(walk);
Stream<RevCommit> reachableCommits = importantRefsFirst(visibleRefs)
.map(UploadPack::refToObjectId)