/** * Convert an AbbreviatedObjectId from an * {@link org.eclipse.jgit.lib.AnyObjectId}. * <p> * This method copies over all bits of the Id, and is therefore complete * (see {@link #isComplete()}). * * @param id * the {@link org.eclipse.jgit.lib.ObjectId} to convert from. * @return the converted object id. */ public static final AbbreviatedObjectId fromObjectId(AnyObjectId id) { return new AbbreviatedObjectId(Constants.OBJECT_ID_STRING_LENGTH, id.w1, id.w2, id.w3, id.w4, id.w5); }
private static final AbbreviatedObjectId fromHexString(final byte[] bs, int ptr, final int end) { try { final int a = hexUInt32(bs, ptr, end); final int b = hexUInt32(bs, ptr + 8, end); final int c = hexUInt32(bs, ptr + 16, end); final int d = hexUInt32(bs, ptr + 24, end); final int e = hexUInt32(bs, ptr + 32, end); return new AbbreviatedObjectId(end - ptr, a, b, c, d, e); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidObjectIdException(bs, ptr, end - ptr); } }
/** * Return an abbreviation (prefix) of this object SHA-1. * <p> * This implementation does not guarantee uniqueness. Callers should instead * use * {@link org.eclipse.jgit.lib.ObjectReader#abbreviate(AnyObjectId, int)} to * obtain a unique abbreviation within the scope of a particular object * database. * * @param len * length of the abbreviated string. * @return SHA-1 abbreviation. */ public AbbreviatedObjectId abbreviate(int len) { final int a = AbbreviatedObjectId.mask(len, 1, w1); final int b = AbbreviatedObjectId.mask(len, 2, w2); final int c = AbbreviatedObjectId.mask(len, 3, w3); final int d = AbbreviatedObjectId.mask(len, 4, w4); final int e = AbbreviatedObjectId.mask(len, 5, w5); return new AbbreviatedObjectId(len, a, b, c, d, e); }
/** * Convert an AbbreviatedObjectId from an {@link AnyObjectId}. * <p> * This method copies over all bits of the Id, and is therefore complete * (see {@link #isComplete()}). * * @param id * the {@link ObjectId} to convert from. * @return the converted object id. */ public static final AbbreviatedObjectId fromObjectId(AnyObjectId id) { return new AbbreviatedObjectId(Constants.OBJECT_ID_STRING_LENGTH, id.w1, id.w2, id.w3, id.w4, id.w5); }
/** * Convert an AbbreviatedObjectId from an * {@link org.eclipse.jgit.lib.AnyObjectId}. * <p> * This method copies over all bits of the Id, and is therefore complete * (see {@link #isComplete()}). * * @param id * the {@link org.eclipse.jgit.lib.ObjectId} to convert from. * @return the converted object id. */ public static final AbbreviatedObjectId fromObjectId(AnyObjectId id) { return new AbbreviatedObjectId(Constants.OBJECT_ID_STRING_LENGTH, id.w1, id.w2, id.w3, id.w4, id.w5); }
private static final AbbreviatedObjectId fromHexString(final byte[] bs, int ptr, final int end) { try { final int a = hexUInt32(bs, ptr, end); final int b = hexUInt32(bs, ptr + 8, end); final int c = hexUInt32(bs, ptr + 16, end); final int d = hexUInt32(bs, ptr + 24, end); final int e = hexUInt32(bs, ptr + 32, end); return new AbbreviatedObjectId(end - ptr, a, b, c, d, e); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidObjectIdException(bs, ptr, end - ptr); } }
private static final AbbreviatedObjectId fromHexString(final byte[] bs, int ptr, final int end) { try { final int a = hexUInt32(bs, ptr, end); final int b = hexUInt32(bs, ptr + 8, end); final int c = hexUInt32(bs, ptr + 16, end); final int d = hexUInt32(bs, ptr + 24, end); final int e = hexUInt32(bs, ptr + 32, end); return new AbbreviatedObjectId(end - ptr, a, b, c, d, e); } catch (ArrayIndexOutOfBoundsException e1) { throw new InvalidObjectIdException(bs, ptr, end - ptr); } }
/** * Return an abbreviation (prefix) of this object SHA-1. * <p> * This implementation does not guarantee uniqueness. Callers should * instead use {@link ObjectReader#abbreviate(AnyObjectId, int)} to obtain a * unique abbreviation within the scope of a particular object database. * * @param len * length of the abbreviated string. * @return SHA-1 abbreviation. */ public AbbreviatedObjectId abbreviate(final int len) { final int a = AbbreviatedObjectId.mask(len, 1, w1); final int b = AbbreviatedObjectId.mask(len, 2, w2); final int c = AbbreviatedObjectId.mask(len, 3, w3); final int d = AbbreviatedObjectId.mask(len, 4, w4); final int e = AbbreviatedObjectId.mask(len, 5, w5); return new AbbreviatedObjectId(len, a, b, c, d, e); }
/** * Return an abbreviation (prefix) of this object SHA-1. * <p> * This implementation does not guarantee uniqueness. Callers should instead * use * {@link org.eclipse.jgit.lib.ObjectReader#abbreviate(AnyObjectId, int)} to * obtain a unique abbreviation within the scope of a particular object * database. * * @param len * length of the abbreviated string. * @return SHA-1 abbreviation. */ public AbbreviatedObjectId abbreviate(int len) { final int a = AbbreviatedObjectId.mask(len, 1, w1); final int b = AbbreviatedObjectId.mask(len, 2, w2); final int c = AbbreviatedObjectId.mask(len, 3, w3); final int d = AbbreviatedObjectId.mask(len, 4, w4); final int e = AbbreviatedObjectId.mask(len, 5, w5); return new AbbreviatedObjectId(len, a, b, c, d, e); }