Source:
private static void checkNotAdvertisedWants(UploadPack up, List<ObjectId> notAdvertisedWants, Set<ObjectId> reachableFrom) throws IOException { ObjectReader reader = up.getRevWalk().getObjectReader(); RevWalk walk = new RevWalk(reader); walk.setRetainBody(false); try { List<RevObject> wantsAsObjs = objectIdsToRevObjects(walk, notAdvertisedWants); List<RevCommit> wantsAsCommits = wantsAsObjs.stream() .filter(obj -> obj instanceof RevCommit) .map(obj -> (RevCommit) obj) .collect(Collectors.toList()); boolean allWantsAreCommits = wantsAsObjs.size() == wantsAsCommits .size(); boolean repoHasBitmaps = reader.getBitmapIndex() != null; if (!allWantsAreCommits) { if (!repoHasBitmaps) { if (up.transferConfig.isAllowFilter()) { try (ObjectWalk objWalk = walk.toObjectWalkWithSameObjects()) { checkReachabilityByWalkingObjects(objWalk, wantsAsObjs, reachableFrom); } return; } RevObject nonCommit = wantsAsObjs .stream() .filter(obj -> !(obj instanceof RevCommit)) .limit(1) .collect(Collectors.toList()).get(0); throw new WantNotValidException(nonCommit); } checkNotAdvertisedWantsUsingBitmap(reader, reader.getBitmapIndex(), notAdvertisedWants, reachableFrom); return; } ReachabilityChecker reachabilityChecker = walk .createReachabilityChecker(); List<RevCommit> starters = objectIdsToRevCommits(walk, reachableFrom); Optional<RevCommit> unreachable = reachabilityChecker .areAllReachable(wantsAsCommits, starters); if (unreachable.isPresent()) { throw new WantNotValidException(unreachable.get()); } } catch (MissingObjectException notFound) { throw new WantNotValidException(notFound.getObjectId(), notFound); } finally { walk.close(); } }

Target:
private static void checkNotAdvertisedWants(UploadPack up, List<ObjectId> notAdvertisedWants, Set<ObjectId> reachableFrom) throws IOException { ObjectReader reader = up.getRevWalk().getObjectReader(); try (RevWalk walk = new RevWalk(reader)) { walk.setRetainBody(false); List<RevObject> wantsAsObjs = objectIdsToRevObjects(walk, notAdvertisedWants); List<RevCommit> wantsAsCommits = wantsAsObjs.stream() .filter(obj -> obj instanceof RevCommit) .map(obj -> (RevCommit) obj) .collect(Collectors.toList()); boolean allWantsAreCommits = wantsAsObjs.size() == wantsAsCommits .size(); boolean repoHasBitmaps = reader.getBitmapIndex() != null; if (!allWantsAreCommits) { if (!repoHasBitmaps) { if (up.transferConfig.isAllowFilter()) { try (ObjectWalk objWalk = walk.toObjectWalkWithSameObjects()) { checkReachabilityByWalkingObjects(objWalk, wantsAsObjs, reachableFrom); } return; } RevObject nonCommit = wantsAsObjs .stream() .filter(obj -> !(obj instanceof RevCommit)) .limit(1) .collect(Collectors.toList()).get(0); throw new WantNotValidException(nonCommit); } checkNotAdvertisedWantsUsingBitmap(reader, reader.getBitmapIndex(), notAdvertisedWants, reachableFrom); return; } ReachabilityChecker reachabilityChecker = walk .createReachabilityChecker(); List<RevCommit> starters = objectIdsToRevCommits(walk, reachableFrom); Optional<RevCommit> unreachable = reachabilityChecker .areAllReachable(wantsAsCommits, starters); if (unreachable.isPresent()) { throw new WantNotValidException(unreachable.get()); } } catch (MissingObjectException notFound) { throw new WantNotValidException(notFound.getObjectId(), notFound); } }