/** * Create a new iterator for an already loaded DirCache instance. * <p> * The iterator implementation may copy part of the cache's data during * construction, so the cache must be read in prior to creating the * iterator. * * @param dcb * the cache builder for the cache to walk. The cache must be * already loaded into memory. */ public DirCacheBuildIterator(DirCacheBuilder dcb) { super(dcb.getDirCache()); builder = dcb; }
/** * Create a new iterator for an already loaded DirCache instance. * <p> * The iterator implementation may copy part of the cache's data during * construction, so the cache must be read in prior to creating the * iterator. * * @param dcb * the cache builder for the cache to walk. The cache must be * already loaded into memory. */ public DirCacheBuildIterator(final DirCacheBuilder dcb) { super(dcb.getDirCache()); builder = dcb; }
/** * Create a new iterator for an already loaded DirCache instance. * <p> * The iterator implementation may copy part of the cache's data during * construction, so the cache must be read in prior to creating the * iterator. * * @param dcb * the cache builder for the cache to walk. The cache must be * already loaded into memory. */ public DirCacheBuildIterator(DirCacheBuilder dcb) { super(dcb.getDirCache()); builder = dcb; }
private DirCache createTreeDirCache(Map<SubtreeConfig, RevCommit> parentCommits, String commitMessage) throws IOException { try (TreeWalk treeWalk = new TreeWalk(repository)) { treeWalk.setRecursive(true); addTrees(parentCommits, treeWalk); DirCacheBuilder builder = DirCache.newInCore().builder(); while (treeWalk.next()) { AbstractTreeIterator iterator = getSingleTreeIterator(treeWalk, commitMessage); if (iterator == null) { throw new IllegalStateException( "Tree walker did not return a single tree (should not happen): " + treeWalk.getPathString()); } byte[] path = Arrays.copyOf(iterator.getEntryPathBuffer(), iterator.getEntryPathLength()); DirCacheEntry entry = new DirCacheEntry(path); entry.setFileMode(iterator.getEntryFileMode()); entry.setObjectId(iterator.getEntryObjectId()); builder.add(entry); } builder.finish(); return builder.getDirCache(); } }