/** * Initialize a new pack parser. * * @param db * database the objects will be imported into. * @param ins * inserter the parser will use to help it inject the objects. * @param in * the stream to parse. */ protected DfsPackParser(DfsObjDatabase db, DfsInserter ins, InputStream in) { super(db, in); this.objdb = db; this.objins = ins; this.crc = new CRC32(); this.packDigest = Constants.newMessageDigest(); }
/** * Create a new writer instance. * * @param dst * the stream this instance outputs to. If not already buffered * it will be automatically wrapped in a buffered stream. */ protected PackIndexWriter(OutputStream dst) { out = new DigestOutputStream(dst instanceof BufferedOutputStream ? dst : new BufferedOutputStream(dst), Constants.newMessageDigest()); tmp = new byte[4 + Constants.OBJECT_ID_LENGTH]; }
private static ObjectId hash(byte[] rawText) { return ObjectId.fromRaw(Constants.newMessageDigest().digest(rawText)); }
/** * Creates the version 1 pack bitmap index files. * * @param dst * the output stream to which the index will be written. */ public PackBitmapIndexWriterV1(final OutputStream dst) { out = new DigestOutputStream(dst instanceof BufferedOutputStream ? dst : new BufferedOutputStream(dst), Constants.newMessageDigest()); dataOutput = new SimpleDataOutput(out); }
final byte[] buf = buffer(); final MessageDigest origDigest = Constants.newMessageDigest(); final MessageDigest tailDigest2 = Constants.newMessageDigest(); final MessageDigest packDigest = Constants.newMessageDigest();
/** * Computes SHA-1 of lexicographically sorted objects ids written in this * pack, as used to name a pack file in repository. * * @return ObjectId representing SHA-1 name of a pack that was created. */ public ObjectId computeName() { final byte[] buf = new byte[OBJECT_ID_LENGTH]; final MessageDigest md = Constants.newMessageDigest(); for (ObjectToPack otp : sortByName()) { otp.copyRawTo(buf, 0); md.update(buf, 0, OBJECT_ID_LENGTH); } return ObjectId.fromRaw(md.digest()); }
ObjectDirectoryPackParser(FileObjectDatabase odb, InputStream src) { super(odb, src); this.db = odb; this.crc = new CRC32(); this.tailDigest = Constants.newMessageDigest(); indexVersion = db.getConfig().get(CoreConfig.KEY).getPackIndexVersion(); }
PackStream(DfsOutputStream out) { this.out = out; hdrBuf = new byte[32]; md = Constants.newMessageDigest(); crc32 = new CRC32(); deflater = new Deflater(compression); compress = new DeflaterOutputStream(this, deflater, 8192); int size = out.blockSize(); if (size <= 0) size = cache.getBlockSize(); else if (size < cache.getBlockSize()) size = (cache.getBlockSize() / size) * size; blockSize = size; currBuf = new byte[blockSize]; }
/** * Initialize a formatter to compute a patch id. */ public PatchIdDiffFormatter() { super(new DigestOutputStream(NullOutputStream.INSTANCE, Constants.newMessageDigest())); digest = ((DigestOutputStream) getOutputStream()).getMessageDigest(); }
while (true) { final FileSnapshot snapshot = FileSnapshot.save(packedRefsFile); final MessageDigest digest = Constants.newMessageDigest(); try (BufferedReader br = new BufferedReader(new InputStreamReader( new DigestInputStream(new FileInputStream(packedRefsFile),
/** * Initialize a pack parser. * * @param odb * database the parser will write its objects into. * @param src * the stream the parser will read. */ protected PackParser(ObjectDatabase odb, InputStream src) { objectDatabase = odb.newCachedDatabase(); in = src; inflater = new InflaterStream(); readCurs = objectDatabase.newReader(); buf = new byte[BUFFER_SIZE]; tempBuffer = new byte[BUFFER_SIZE]; hdrBuf = new byte[64]; tempObjectId = new MutableObjectId(); packDigest = Constants.newMessageDigest(); checkObjectCollisions = true; }
final MessageDigest d = Constants.newMessageDigest(); final byte[] oeBytes = new byte[Constants.OBJECT_ID_LENGTH]; for (int i = 0; i < getObjectCount(); i++) {
throw new ObjectWritingException(MessageFormat.format(JGitText.get().unableToWrite, name)); byte[] digest = Constants.newMessageDigest().digest(content); PackedRefList newPackedList = new PackedRefList( refs, lck.getCommitSnapshot(), ObjectId.fromRaw(digest));
private void readFrom(InputStream inStream) throws IOException, CorruptObjectException { final BufferedInputStream in = new BufferedInputStream(inStream); final MessageDigest md = Constants.newMessageDigest();
void writeTo(File dir, OutputStream os) throws IOException { final MessageDigest foot = Constants.newMessageDigest(); final DigestOutputStream dos = new DigestOutputStream(os, foot);
@SuppressWarnings("boxing") private boolean isValid() { Boolean v = valid; if (v == null) { MessageDigest m = newMessageDigest(); m.update(dataBuf, dataPtr, dataLen); v = key.getChunkHash().compareTo(m.digest(), 0) == 0; valid = v; } return v.booleanValue(); }
private ObjectId computePackName() { byte[] buf = new byte[Constants.OBJECT_ID_LENGTH]; MessageDigest md = Constants.newMessageDigest(); for (DhtInfo otp : objectListByName) { otp.copyRawTo(buf, 0); md.update(buf); } return ObjectId.fromRaw(md.digest()); }
private ObjectId computePackName() { byte[] buf = new byte[Constants.OBJECT_ID_LENGTH]; MessageDigest md = Constants.newMessageDigest(); for (DhtInfo otp : objectListByName) { otp.copyRawTo(buf, 0); md.update(buf); } return ObjectId.fromRaw(md.digest()); }
private static void assertHash(RevObject id, byte[] bin) { MessageDigest md = Constants.newMessageDigest(); md.update(Constants.encodedTypeString(id.getType())); md.update((byte) ' '); md.update(Constants.encodeASCII(bin.length)); md.update((byte) 0); md.update(bin); assertEquals(id, ObjectId.fromRaw(md.digest())); }
/** * Creates the version 1 pack bitmap index files. * * @param dst * the output stream to which the index will be written. */ public PackBitmapIndexWriterV1(final OutputStream dst) { out = new DigestOutputStream(dst instanceof BufferedOutputStream ? dst : new SafeBufferedOutputStream(dst), Constants.newMessageDigest()); dataOutput = new SimpleDataOutput(out); }