use of org.eclipse.jgit.lib.Constants.R_HEADS in project gitiles by GerritCodeReview.
the class VisibilityCache method isVisible.
private boolean isVisible(Repository repo, RevWalk walk, ObjectId id, Collection<ObjectId> knownReachable) throws IOException {
RevCommit commit;
try {
commit = walk.parseCommit(id);
} catch (IncorrectObjectTypeException e) {
return false;
}
// If any reference directly points at the requested object, permit display. Common for displays
// of pending patch sets in Gerrit Code Review, or bookmarks to the commit a tag points at.
Collection<Ref> all = repo.getRefDatabase().getRefs(RefDatabase.ALL).values();
for (Ref ref : all) {
ref = repo.getRefDatabase().peel(ref);
if (id.equals(ref.getObjectId()) || id.equals(ref.getPeeledObjectId())) {
return true;
}
}
// case.
return isReachableFrom(walk, commit, knownReachable) || isReachableFromRefs(walk, commit, all.stream().filter(r -> refStartsWith(r, R_HEADS))) || isReachableFromRefs(walk, commit, all.stream().filter(r -> refStartsWith(r, R_TAGS))) || isReachableFromRefs(walk, commit, all.stream().filter(r -> otherRefs(r)));
}
Aggregations