baseObjects = parser.getBaseObjectIds();
providedObjects = parser.getNewObjectIds();
}
parser = null;
final ObjectWalk ow = new ObjectWalk(db);
ow.setRetainBody(false);
if (checkReferencedIsReachable) {
ow.sort(RevSort.TOPO);
if (!baseObjects.isEmpty())
ow.sort(RevSort.BOUNDARY, true);
}
for (final ReceiveCommand cmd : commands) {
if (cmd.getResult() != Result.NOT_ATTEMPTED)
continue;
if (cmd.getType() == ReceiveCommand.Type.DELETE)
continue;
ow.markStart(ow.parseAny(cmd.getNewId()));
}
for (final ObjectId have : advertisedHaves) {
RevObject o = ow.parseAny(have);
ow.markUninteresting(o);
if (checkReferencedIsReachable && !baseObjects.isEmpty()) {
o = ow.peel(o);
if (o instanceof RevCommit)
o = ((RevCommit) o).getTree();
if (o instanceof RevTree)
ow.markUninteresting(o);
}
}
RevCommit c;
while ((c = ow.next()) != null) {
if (checkReferencedIsReachable //
&& !c.has(RevFlag.UNINTERESTING) //
&& !providedObjects.contains(c))
throw new MissingObjectException(c, Constants.TYPE_COMMIT);
}
RevObject o;
while ((o = ow.nextObject()) != null) {
if (o.has(RevFlag.UNINTERESTING))
continue;
if (checkReferencedIsReachable) {
if (providedObjects.contains(o))
continue;
else
throw new MissingObjectException(o, o.getType());
}
if (o instanceof RevBlob && !db.hasObject(o))
throw new MissingObjectException(o, Constants.TYPE_BLOB);
}
if (checkReferencedIsReachable) {
for (ObjectId id : baseObjects) {
o = ow.parseAny(id);
if (!o.has(RevFlag.UNINTERESTING))
throw new MissingObjectException(o, o.getType());
}
}
}