byte[] finishPack() throws IOException { // Overwrite placeholder header with actual object count, then hash. This // method intentionally uses direct seek/write calls rather than the // wrappers which keep track of atEnd. This leaves atEnd, the file // pointer, and out's counter in an inconsistent state; that's ok, since // this method closes the file anyway. try { file.seek(0); out.write(hdrBuf, 0, writePackHeader(hdrBuf, objectList.size())); byte[] buf = buffer(); SHA1 md = digest().reset(); file.seek(0); while (true) { int r = file.read(buf); if (r < 0) { break; } md.update(buf, 0, r); } byte[] packHash = md.digest(); out.write(packHash, 0, packHash.length); return packHash; } finally { close(); } }
private ObjectId computeName(List<PackedObjectInfo> list) { SHA1 md = digest().reset(); byte[] buf = buffer(); for (PackedObjectInfo otp : list) { otp.copyRawTo(buf, 0); md.update(buf, 0, OBJECT_ID_LENGTH); } return ObjectId.fromRaw(md.digest()); }
private byte[] computeHash(InputStream in, long length) throws IOException { SHA1 contentDigest = SHA1.newInstance(); final byte[] contentReadBuffer = state.contentReadBuffer; contentDigest.update(hblob); contentDigest.update((byte) ' '); long sz = length; if (sz == 0) { contentDigest.update((byte) '0'); } else { final int bufn = contentReadBuffer.length; int p = bufn; do { contentReadBuffer[--p] = digits[(int) (sz % 10)]; sz /= 10; } while (sz > 0); contentDigest.update(contentReadBuffer, p, bufn - p); } contentDigest.update((byte) 0); for (;;) { final int r = in.read(contentReadBuffer); if (r <= 0) break; contentDigest.update(contentReadBuffer, 0, r); sz += r; } if (sz != length) return zeroid; return contentDigest.digest(); }
objectDigest.update((byte) 0); objectDigest.update(visit.data); objectDigest.digest(tempObjectId);
byte[] finishPack() throws IOException { // Overwrite placeholder header with actual object count, then hash. This // method intentionally uses direct seek/write calls rather than the // wrappers which keep track of atEnd. This leaves atEnd, the file // pointer, and out's counter in an inconsistent state; that's ok, since // this method closes the file anyway. try { file.seek(0); out.write(hdrBuf, 0, writePackHeader(hdrBuf, objectList.size())); byte[] buf = buffer(); SHA1 md = digest().reset(); file.seek(0); while (true) { int r = file.read(buf); if (r < 0) { break; } md.update(buf, 0, r); } byte[] packHash = md.digest(); out.write(packHash, 0, packHash.length); return packHash; } finally { close(); } }
private ObjectId computeName(List<PackedObjectInfo> list) { SHA1 md = digest().reset(); byte[] buf = buffer(); for (PackedObjectInfo otp : list) { otp.copyRawTo(buf, 0); md.update(buf, 0, OBJECT_ID_LENGTH); } return ObjectId.fromRaw(md.digest()); }
private byte[] computeHash(InputStream in, long length) throws IOException { SHA1 contentDigest = SHA1.newInstance(); final byte[] contentReadBuffer = state.contentReadBuffer; contentDigest.update(hblob); contentDigest.update((byte) ' '); long sz = length; if (sz == 0) { contentDigest.update((byte) '0'); } else { final int bufn = contentReadBuffer.length; int p = bufn; do { contentReadBuffer[--p] = digits[(int) (sz % 10)]; sz /= 10; } while (sz > 0); contentDigest.update(contentReadBuffer, p, bufn - p); } contentDigest.update((byte) 0); for (;;) { final int r = in.read(contentReadBuffer); if (r <= 0) break; contentDigest.update(contentReadBuffer, 0, r); sz += r; } if (sz != length) return zeroid; return contentDigest.digest(); }
objectDigest.update((byte) 0); objectDigest.update(visit.data); objectDigest.digest(tempObjectId);