/** * Convert an ObjectId from raw binary representation. * * @param bs * the raw byte buffer to read from. At least 20 bytes must be * available within this byte array. * @return the converted object id. */ public static final ObjectId fromRaw(byte[] bs) { return fromRaw(bs, 0); }
/** * Convert an ObjectId from raw binary representation. * * @param is * the raw integers buffer to read from. At least 5 integers must * be available within this int array. * @return the converted object id. */ public static final ObjectId fromRaw(int[] is) { return fromRaw(is, 0); }
private ObjectId readValueId() { ObjectId id = ObjectId.fromRaw(buf, ptr); ptr += OBJECT_ID_LENGTH; return id; }
/** * Should be called after having called one of the format methods * * @return the patch id calculated for the provided diff. */ public ObjectId getCalulatedPatchId() { return ObjectId.fromRaw(digest.digest()); }
private static ObjectId hash(byte[] rawText) { return ObjectId.fromRaw(Constants.newMessageDigest().digest(rawText)); }
/** {@inheritDoc} */ @Override public ObjectId getObjectId(long nthPosition) { final int levelOne = findLevelOne(nthPosition); final int p = getLevelTwo(nthPosition, levelOne); final int p4 = p << 2; return ObjectId.fromRaw(names[levelOne], p4 + p); // p * 5 }
/** * Obtain the ObjectId for the entry. * <p> * Using this method to compare ObjectId values between entries is * inefficient as it causes memory allocation. * * @return object identifier for the entry. */ public ObjectId getObjectId() { return ObjectId.fromRaw(idBuffer(), idOffset()); }
/** * Get the object id of the current entry. * * @return an object id for the current entry. */ public ObjectId getEntryObjectId() { return ObjectId.fromRaw(idBuffer(), idOffset()); }
/** * 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()); }
/** * Read a non-null {@link ObjectId} from the stream. * * @param in * the input stream * @return the object id; never null * @throws IOException * there was an error reading the stream * @since 4.11 */ @NonNull public static ObjectId readWithoutMarker(InputStream in) throws IOException { final byte[] b = new byte[OBJECT_ID_LENGTH]; IO.readFully(in, b, 0, OBJECT_ID_LENGTH); return ObjectId.fromRaw(b); }
try { return new PackedRefList(parsePackedRefs(br), snapshot, ObjectId.fromRaw(digest.digest())); } catch (IOException e) { if (FileUtils.isStaleFileHandleInCausalChain(e)
/** {@inheritDoc} */ @Override public ObjectId getObjectId(long nthPosition) { final int levelOne = findLevelOne(nthPosition); final int p = getLevelTwo(nthPosition, levelOne); final int dataIdx = idOffset(p); return ObjectId.fromRaw(idxdata[levelOne], dataIdx); }
c = ib[p++] & 0xff; readFully(pos + p, ib, 0, 20, ctx); pos = findDeltaBase(ctx, ObjectId.fromRaw(ib)); continue;
id = ObjectId.fromRaw(in, off.value); off.value += Constants.OBJECT_ID_LENGTH;
readFully(pos + p, ib, 0, 20, ctx); r.format = StoredObjectRepresentation.PACK_DELTA; r.baseId = ObjectId.fromRaw(ib); r.length = len - p - 20; return;
private void onOpenPack() throws IOException { final PackIndex idx = idx(); final byte[] buf = new byte[20]; fd.seek(0); fd.readFully(buf, 0, 12); if (RawParseUtils.match(buf, 0, Constants.PACK_SIGNATURE) != 4) { throw new NoPackSignatureException(JGitText.get().notAPACKFile); } final long vers = NB.decodeUInt32(buf, 4); final long packCnt = NB.decodeUInt32(buf, 8); if (vers != 2 && vers != 3) { throw new UnsupportedPackVersionException(vers); } if (packCnt != idx.getObjectCount()) { throw new PackMismatchException(MessageFormat.format( JGitText.get().packObjectCountMismatch, Long.valueOf(packCnt), Long.valueOf(idx.getObjectCount()), getPackFile())); } fd.seek(length - 20); fd.readFully(buf, 0, 20); if (!Arrays.equals(buf, packChecksum)) { throw new PackMismatchException(MessageFormat.format( JGitText.get().packObjectCountMismatch , ObjectId.fromRaw(buf).name() , ObjectId.fromRaw(idx.packChecksum).name() , getPackFile())); } }
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()); }
p--; for (; p < max && id.prefixCompare(data, idOffset(p)) == 0; p++) { matches.add(ObjectId.fromRaw(data, idOffset(p))); if (matches.size() > matchLimit) break;
len -= Constants.OBJECT_ID_LENGTH; readFully(pos + p, ib, 0, 20, curs); ObjectId id = ObjectId.fromRaw(ib); return LocalObjectRepresentation.newDelta(this, pos, len, id);
p--; for (; p < max && id.prefixCompare(data, idOffset(p)) == 0; p++) { matches.add(ObjectId.fromRaw(data, idOffset(p))); if (matches.size() > matchLimit) break;