diff options
author | Ivan Frade <ifrade@google.com> | 2020-04-03 23:20:27 -0700 |
---|---|---|
committer | Ivan Frade <ifrade@google.com> | 2020-04-28 22:44:39 -0700 |
commit | 6bc04bdc026bc48811f01e3e4acca816d1e7d087 (patch) | |
tree | aeaf990cd50acca95aa91eeba8d9e075f9347d3b /org.eclipse.jgit/src/org/eclipse/jgit/transport | |
parent | 003002c1cbc140502eb9066b43c8c56796947f85 (diff) | |
download | jgit-6bc04bdc026bc48811f01e3e4acca816d1e7d087.tar.gz jgit-6bc04bdc026bc48811f01e3e4acca816d1e7d087.zip |
UploadPack: Use BitmappedReachabilityChecker for not advertised wants
Change-Id: Ifea971d5c0309e28a909441ee8a6f1e62397d6d3
Signed-off-by: Ivan Frade <ifrade@google.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/transport')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 30 |
1 files changed, 12 insertions, 18 deletions
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 cfa6958ef9..95e2e5a145 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -66,8 +66,6 @@ import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.internal.storage.pack.CachedPackUriProvider; import org.eclipse.jgit.internal.storage.pack.PackWriter; import org.eclipse.jgit.internal.transport.parser.FirstWant; -import org.eclipse.jgit.lib.BitmapIndex; -import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.NullProgressMonitor; import org.eclipse.jgit.lib.ObjectId; @@ -77,7 +75,7 @@ import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefDatabase; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.AsyncRevObjectQueue; -import org.eclipse.jgit.revwalk.BitmapWalker; +import org.eclipse.jgit.revwalk.BitmappedObjectReachabilityChecker; import org.eclipse.jgit.revwalk.DepthWalk; import org.eclipse.jgit.revwalk.ObjectReachabilityChecker; import org.eclipse.jgit.revwalk.ObjectWalk; @@ -1899,18 +1897,6 @@ public class UploadPack { } } - private static void checkNotAdvertisedWantsUsingBitmap(ObjectReader reader, - BitmapIndex bitmapIndex, List<ObjectId> notAdvertisedWants, - Set<ObjectId> reachableFrom) throws IOException { - BitmapWalker bitmapWalker = new BitmapWalker(new ObjectWalk(reader), bitmapIndex, null); - BitmapBuilder reachables = bitmapWalker.findObjects(reachableFrom, null, false); - for (ObjectId oid : notAdvertisedWants) { - if (!reachables.contains(oid)) { - throw new WantNotValidException(oid); - } - } - } - private static void checkNotAdvertisedWants(UploadPack up, List<ObjectId> notAdvertisedWants, Collection<Ref> visibleRefs) throws IOException { @@ -1965,9 +1951,17 @@ public class UploadPack { throw new WantNotValidException(nonCommit); } - checkNotAdvertisedWantsUsingBitmap(reader, - reader.getBitmapIndex(), notAdvertisedWants, - reachableFrom); + try (ObjectWalk objWalk = walk.toObjectWalkWithSameObjects()) { + List<RevObject> havesAsObjs = objectIdsToRevObjects(objWalk, + reachableFrom); + ObjectReachabilityChecker reachabilityChecker = new BitmappedObjectReachabilityChecker( + objWalk); + Optional<RevObject> unreachable = reachabilityChecker + .areAllReachable(wantsAsObjs, havesAsObjs.stream()); + if (unreachable.isPresent()) { + throw new WantNotValidException(unreachable.get()); + } + } return; } |