/** {@inheritDoc} */ @Override public void writeShort(int v) throws IOException { NB.encodeInt16(buf, 0, v); fd.write(buf, 0, 2); }
void writeInt16(int val) { ensureBytesAvailableInBlockBuf(2); NB.encodeInt16(blockBuf, cur, val); cur += 2; }
/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path and possibly stage from one * entry to another, supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. * @param keepStage * if true, the stage attribute will not be copied */ void copyMetaData(DirCacheEntry src, boolean keepStage) { int origflags = NB.decodeUInt16(info, infoOffset + P_FLAGS); int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS); System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN); final int pLen = origflags & NAME_MASK; final int SHIFTED_STAGE_MASK = 0x3 << 12; final int pStageShifted; if (keepStage) pStageShifted = origflags & SHIFTED_STAGE_MASK; else pStageShifted = newflags & SHIFTED_STAGE_MASK; NB.encodeInt16(info, infoOffset + P_FLAGS, pStageShifted | pLen | (newflags & ~NAME_MASK & ~SHIFTED_STAGE_MASK)); }
/** * Create an empty entry at the specified stage. * * @param path * name of the cache entry, in the standard encoding. * @param stage * the stage index of the new entry. * @throws java.lang.IllegalArgumentException * If the path starts or ends with "/", or contains "//" either * "\0". These sequences are not permitted in a git tree object * or DirCache file. Or if {@code stage} is outside of the * range 0..3, inclusive. */ @SuppressWarnings("boxing") public DirCacheEntry(byte[] path, int stage) { checkPath(path); if (stage < 0 || 3 < stage) throw new IllegalArgumentException(MessageFormat.format( JGitText.get().invalidStageForPath, stage, toString(path))); info = new byte[INFO_LEN]; infoOffset = 0; this.path = path; int flags = ((stage & 0x3) << 12); if (path.length < NAME_MASK) flags |= path.length; else flags |= NAME_MASK; NB.encodeInt16(info, infoOffset + P_FLAGS, flags); }
/** {@inheritDoc} */ @Override public void writeShort(int v) throws IOException { NB.encodeInt16(buf, 0, v); fd.write(buf, 0, 2); }
public void writeShort(int v) throws IOException { NB.encodeInt16(buf, 0, v); fd.write(buf, 0, 2); }
void writeInt16(int val) { ensureBytesAvailableInBlockBuf(2); NB.encodeInt16(blockBuf, cur, val); cur += 2; }
/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path and possibly stage from one * entry to another, supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. * @param keepStage * if true, the stage attribute will not be copied */ void copyMetaData(DirCacheEntry src, boolean keepStage) { int origflags = NB.decodeUInt16(info, infoOffset + P_FLAGS); int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS); System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN); final int pLen = origflags & NAME_MASK; final int SHIFTED_STAGE_MASK = 0x3 << 12; final int pStageShifted; if (keepStage) pStageShifted = origflags & SHIFTED_STAGE_MASK; else pStageShifted = newflags & SHIFTED_STAGE_MASK; NB.encodeInt16(info, infoOffset + P_FLAGS, pStageShifted | pLen | (newflags & ~NAME_MASK & ~SHIFTED_STAGE_MASK)); }
/** * Copy the ObjectId and other meta fields from an existing entry. * <p> * This method copies everything except the path and possibly stage from one * entry to another, supporting renaming. * * @param src * the entry to copy ObjectId and meta fields from. * @param keepStage * if true, the stage attribute will not be copied */ void copyMetaData(final DirCacheEntry src, boolean keepStage) { int origflags = NB.decodeUInt16(info, infoOffset + P_FLAGS); int newflags = NB.decodeUInt16(src.info, src.infoOffset + P_FLAGS); System.arraycopy(src.info, src.infoOffset, info, infoOffset, INFO_LEN); final int pLen = origflags & NAME_MASK; final int SHIFTED_STAGE_MASK = 0x3 << 12; final int pStageShifted; if (keepStage) pStageShifted = origflags & SHIFTED_STAGE_MASK; else pStageShifted = newflags & SHIFTED_STAGE_MASK; NB.encodeInt16(info, infoOffset + P_FLAGS, pStageShifted | pLen | (newflags & ~NAME_MASK & ~SHIFTED_STAGE_MASK)); }
/** * Create an empty entry at the specified stage. * * @param path * name of the cache entry, in the standard encoding. * @param stage * the stage index of the new entry. * @throws java.lang.IllegalArgumentException * If the path starts or ends with "/", or contains "//" either * "\0". These sequences are not permitted in a git tree object * or DirCache file. Or if {@code stage} is outside of the * range 0..3, inclusive. */ @SuppressWarnings("boxing") public DirCacheEntry(byte[] path, int stage) { checkPath(path); if (stage < 0 || 3 < stage) throw new IllegalArgumentException(MessageFormat.format( JGitText.get().invalidStageForPath, stage, toString(path))); info = new byte[INFO_LEN]; infoOffset = 0; this.path = path; int flags = ((stage & 0x3) << 12); if (path.length < NAME_MASK) flags |= path.length; else flags |= NAME_MASK; NB.encodeInt16(info, infoOffset + P_FLAGS, flags); }
/** * Create an empty entry at the specified stage. * * @param path * name of the cache entry, in the standard encoding. * @param stage * the stage index of the new entry. * @throws IllegalArgumentException * If the path starts or ends with "/", or contains "//" either * "\0". These sequences are not permitted in a git tree object * or DirCache file. Or if {@code stage} is outside of the * range 0..3, inclusive. */ @SuppressWarnings("boxing") public DirCacheEntry(byte[] path, final int stage) { checkPath(path); if (stage < 0 || 3 < stage) throw new IllegalArgumentException(MessageFormat.format( JGitText.get().invalidStageForPath, stage, toString(path))); info = new byte[INFO_LEN]; infoOffset = 0; this.path = path; int flags = ((stage & 0x3) << 12); if (path.length < NAME_MASK) flags |= path.length; else flags |= NAME_MASK; NB.encodeInt16(info, infoOffset + P_FLAGS, flags); }
case 2: for (int i = 0; i < 256; i++, ptr += 2) NB.encodeInt16(index, ptr, buckets[i]); break; case 3: NB.encodeInt16(index, ptr, (int) oe.getOffset()); ptr += 2;
case 2: for (int i = 0; i < 256; i++, ptr += 2) NB.encodeInt16(index, ptr, buckets[i]); break; case 3: NB.encodeInt16(index, ptr, (int) oe.getOffset()); ptr += 2;