}
private static byte[] getDelta(ObjectReader reader, RevObject obj)
throws IOException, MissingObjectException,
StoredObjectRepresentationNotAvailableException {
ObjectReuseAsIs asis = (ObjectReuseAsIs) reader;
ObjectToPack target = asis.newObjectToPack(obj, obj.getType());
PackWriter pw = new PackWriter(reader) {
@Override
public void select(ObjectToPack otp, StoredObjectRepresentation next) {
otp.select(next);
}
};
ByteArrayOutputStream buf = new ByteArrayOutputStream();
asis.selectObjectRepresentation(pw, NullProgressMonitor.INSTANCE,
Collections.singleton(target));
asis.copyObjectAsIs(new PackOutputStream(NullProgressMonitor.INSTANCE,
buf, pw), target, true);
// At this point the object header has no delta information,
// because it was output as though it were a whole object.
// Skip over the header and inflate.