/** * Write all index trees to the object store, returning the root tree. * * @param ow * the writer to use when serializing to the store. The caller is * responsible for flushing the inserter before trying to use the * returned tree identity. * @return identity for the root tree. * @throws org.eclipse.jgit.errors.UnmergedPathException * one or more paths contain higher-order stages (stage > 0), * which cannot be stored in a tree object. * @throws java.lang.IllegalStateException * one or more paths contain an invalid mode which should never * appear in a tree object. * @throws java.io.IOException * an unexpected error occurred writing to the object store. */ public ObjectId writeTree(ObjectInserter ow) throws UnmergedPathException, IOException { return getCacheTree(true).writeTree(sortedEntries, 0, 0, ow); }
private int computeSize(final DirCacheEntry[] cache, int cIdx, final int pathOffset, final ObjectInserter ow) throws UnmergedPathException, IOException { final int endIdx = cIdx + entrySpan; int childIdx = 0; int entryIdx = cIdx; int size = 0; while (entryIdx < endIdx) { final DirCacheEntry e = cache[entryIdx]; if (e.getStage() != 0) throw new UnmergedPathException(e); final byte[] ep = e.path; if (childIdx < childCnt) { final DirCacheTree st = children[childIdx]; if (st.contains(ep, pathOffset, ep.length)) { final int stOffset = pathOffset + st.nameLength() + 1; st.writeTree(cache, entryIdx, stOffset, ow); size += entrySize(TREE, st.nameLength()); entryIdx += st.entrySpan; childIdx++; continue; } } size += entrySize(e.getFileMode(), ep.length - pathOffset); entryIdx++; } return size; }
/** * Write all index trees to the object store, returning the root tree. * * @param ow * the writer to use when serializing to the store. The caller is * responsible for flushing the inserter before trying to use the * returned tree identity. * @return identity for the root tree. * @throws UnmergedPathException * one or more paths contain higher-order stages (stage > 0), * which cannot be stored in a tree object. * @throws IllegalStateException * one or more paths contain an invalid mode which should never * appear in a tree object. * @throws IOException * an unexpected error occurred writing to the object store. */ public ObjectId writeTree(final ObjectInserter ow) throws UnmergedPathException, IOException { return getCacheTree(true).writeTree(sortedEntries, 0, 0, ow); }
/** * Write all index trees to the object store, returning the root tree. * * @param ow * the writer to use when serializing to the store. The caller is * responsible for flushing the inserter before trying to use the * returned tree identity. * @return identity for the root tree. * @throws org.eclipse.jgit.errors.UnmergedPathException * one or more paths contain higher-order stages (stage > 0), * which cannot be stored in a tree object. * @throws java.lang.IllegalStateException * one or more paths contain an invalid mode which should never * appear in a tree object. * @throws java.io.IOException * an unexpected error occurred writing to the object store. */ public ObjectId writeTree(ObjectInserter ow) throws UnmergedPathException, IOException { return getCacheTree(true).writeTree(sortedEntries, 0, 0, ow); }
private int computeSize(final DirCacheEntry[] cache, int cIdx, final int pathOffset, final ObjectInserter ow) throws UnmergedPathException, IOException { final int endIdx = cIdx + entrySpan; int childIdx = 0; int entryIdx = cIdx; int size = 0; while (entryIdx < endIdx) { final DirCacheEntry e = cache[entryIdx]; if (e.getStage() != 0) throw new UnmergedPathException(e); final byte[] ep = e.path; if (childIdx < childCnt) { final DirCacheTree st = children[childIdx]; if (st.contains(ep, pathOffset, ep.length)) { final int stOffset = pathOffset + st.nameLength() + 1; st.writeTree(cache, entryIdx, stOffset, ow); size += entrySize(TREE, st.nameLength()); entryIdx += st.entrySpan; childIdx++; continue; } } size += entrySize(e.getFileMode(), ep.length - pathOffset); entryIdx++; } return size; }
private int computeSize(final DirCacheEntry[] cache, int cIdx, final int pathOffset, final ObjectInserter ow) throws UnmergedPathException, IOException { final int endIdx = cIdx + entrySpan; int childIdx = 0; int entryIdx = cIdx; int size = 0; while (entryIdx < endIdx) { final DirCacheEntry e = cache[entryIdx]; if (e.getStage() != 0) throw new UnmergedPathException(e); final byte[] ep = e.path; if (childIdx < childCnt) { final DirCacheTree st = children[childIdx]; if (st.contains(ep, pathOffset, ep.length)) { final int stOffset = pathOffset + st.nameLength() + 1; st.writeTree(cache, entryIdx, stOffset, ow); size += entrySize(TREE, st.nameLength()); entryIdx += st.entrySpan; childIdx++; continue; } } size += entrySize(e.getFileMode(), ep.length - pathOffset); entryIdx++; } return size; }