/** * Get string form of the SHA-1, in lower case hexadecimal. * * @return string form of the SHA-1, in lower case hexadecimal. */ public final String getName() { return name(); }
public static Memory valueOf(AnyObjectId value) { return value == null ? Memory.NULL : StringMemory.valueOf(value.getName()); }
/** * Determine if this ObjectId has exactly the same value as another. * * @param other * the other id to compare to. May be null. * @return true only if both ObjectIds have identical bits. */ public final boolean equals(AnyObjectId other) { return other != null ? equals(this, other) : false; }
/** {@inheritDoc} */ @Override public long findOffset(AnyObjectId objId) { final int levelOne = objId.getFirstByte(); byte[] data = idxdata[levelOne]; if (data == null) return -1; int high = data.length / (4 + Constants.OBJECT_ID_LENGTH); int low = 0; do { final int mid = (low + high) >>> 1; final int pos = idOffset(mid); final int cmp = objId.compareTo(data, pos); if (cmp < 0) high = mid; else if (cmp == 0) { int b0 = data[pos - 4] & 0xff; int b1 = data[pos - 3] & 0xff; int b2 = data[pos - 2] & 0xff; int b3 = data[pos - 1] & 0xff; return (((long) b0) << 24) | (b1 << 16) | (b2 << 8) | (b3); } else low = mid + 1; } while (low < high); return -1; }
boolean add(AnyObjectId toAdd) { int i = index(toAdd); for (int n = 0; n < MAX_CHAIN;) { ObjectId obj = ids.get(i); if (obj == null) { if (ids.compareAndSet(i, null, toAdd.copy())) return true; else continue; } if (AnyObjectId.equals(obj, toAdd)) return true; if (++i == ids.length()) i = 0; n++; } return false; }
/** {@inheritDoc} */ @Override public long findCRC32(AnyObjectId objId) throws MissingObjectException { final int levelOne = objId.getFirstByte(); final int levelTwo = binarySearchLevelTwo(objId, levelOne); if (levelTwo == -1) throw new MissingObjectException(objId.copy(), "unknown"); //$NON-NLS-1$ return NB.decodeUInt32(crc32[levelOne], levelTwo << 2); }
/** * Set the identity of the object, if its not already set. * * @param id * the id of the object that is too large to process. */ public void setObjectId(AnyObjectId id) { if (objectId == null) objectId = id.copy(); }
e = new FileNotFoundException(id.name()); e.initCause(parsingError); throw e; throw new TransportException(MessageFormat.format( JGitText.get().transportExceptionInvalid, Constants.typeString(type), id.name(), e.getMessage())); if (!AnyObjectId.equals(id, act)) { throw new TransportException(MessageFormat.format( JGitText.get().incorrectHashFor, id.name(), act.name(), Constants.typeString(type), Integer.valueOf(compressed.length)));
/** * Write a non-null {@link ObjectId} to the stream. * * @param out * the output stream * @param id * the object id to serialize; never null * @throws IOException * the stream writing failed * @since 4.11 */ public static void writeWithoutMarker(OutputStream out, @NonNull AnyObjectId id) throws IOException { id.copyRawTo(out); }
/** * Set start commit id * * @param commit * id of a commit * @return this command */ public BlameCommand setStartCommit(AnyObjectId commit) { this.startCommit = commit.toObjectId(); return this; }
private int search(AnyObjectId objId) { int low = 0; int high = cnt; while (low < high) { int mid = (low + high) >>> 1; int cmp = objId.compareTo(notes[mid]); if (cmp < 0) high = mid; else if (cmp == 0) return mid; else low = mid + 1; } return -(low + 1); }
/** {@inheritDoc} */ @Override public long findOffset(AnyObjectId objId) { final int levelOne = objId.getFirstByte(); final int levelTwo = binarySearchLevelTwo(objId, levelOne); if (levelTwo == -1) return -1; return getOffset(levelOne, levelTwo); }
LargeObject(int type, long size, File path, AnyObjectId id, FileObjectDatabase db) { this.type = type; this.size = size; this.path = path; this.id = id.copy(); this.source = db; }
@Override public long findOffset(final AnyObjectId objId) { final int levelOne = objId.getFirstByte(); byte[] data = idxdata[levelOne]; if (data == null) return -1; int high = data.length / (4 + Constants.OBJECT_ID_LENGTH); int low = 0; do { final int mid = (low + high) >>> 1; final int pos = idOffset(mid); final int cmp = objId.compareTo(data, pos); if (cmp < 0) high = mid; else if (cmp == 0) { int b0 = data[pos - 4] & 0xff; int b1 = data[pos - 3] & 0xff; int b2 = data[pos - 2] & 0xff; int b3 = data[pos - 1] & 0xff; return (((long) b0) << 24) | (b1 << 16) | (b2 << 8) | (b3); } else low = mid + 1; } while (low < high); return -1; }
@Override public long findCRC32(AnyObjectId objId) throws MissingObjectException { final int levelOne = objId.getFirstByte(); final int levelTwo = binarySearchLevelTwo(objId, levelOne); if (levelTwo == -1) throw new MissingObjectException(objId.copy(), "unknown"); //$NON-NLS-1$ return NB.decodeUInt32(crc32[levelOne], levelTwo << 2); }
/** * Set the ObjectId for the entry. * * @param id * new object identifier for the entry. May be * {@link org.eclipse.jgit.lib.ObjectId#zeroId()} to remove the * current identifier. */ public void setObjectId(AnyObjectId id) { id.copyRawTo(idBuffer(), idOffset()); }
/** * Set the expected value of the ref after the lock is taken, but before * update occurs. * * @param id * the expected value of the ref after the lock is taken, but * before update occurs. Null to avoid the compare and swap test. * Use {@link org.eclipse.jgit.lib.ObjectId#zeroId()} to indicate * expectation of a non-existant ref. */ public void setExpectedOldObjectId(AnyObjectId id) { expValue = id != null ? id.toObjectId() : null; }
private int binarySearchLevelTwo(AnyObjectId objId, int levelOne) { final int[] data = names[levelOne]; int high = offset32[levelOne].length >>> 2; if (high == 0) return -1; int low = 0; do { final int mid = (low + high) >>> 1; final int mid4 = mid << 2; final int cmp; cmp = objId.compareTo(data, mid4 + mid); // mid * 5 if (cmp < 0) high = mid; else if (cmp == 0) { return mid; } else low = mid + 1; } while (low < high); return -1; }
@Override public long findOffset(final AnyObjectId objId) { final int levelOne = objId.getFirstByte(); final int levelTwo = binarySearchLevelTwo(objId, levelOne); if (levelTwo == -1) return -1; return getOffset(levelOne, levelTwo); }
/** {@inheritDoc} */ @SuppressWarnings("nls") @Override public String toString() { return "AnyObjectId[" + name() + "]"; }