private byte[] contentFromTree(RevTree tree) { try { final ObjectReader reader = gitRepo.newObjectReader(); CanonicalTreeParser parser = new CanonicalTreeParser(); parser.reset(reader, tree); String lastPath = null; while (true) { final String path = parser.getEntryPathString(); parser = parser.next(); if (path.equals(lastPath)) { break; } lastPath = path; if (path.equals(CRUISE_CONFIG_XML)) { final ObjectId id = parser.getEntryObjectId(); final ObjectLoader loader = reader.open(id); return loader.getBytes(); } } return null; } catch (IOException e) { LOGGER.error("Could not fetch content from the config repository found at path '{}'", workingDir.getAbsolutePath(), e); throw new RuntimeException("Error while fetching content from the config repository.", e); } }
private static CanonicalTreeParser createTreeParser(byte[] pathPrefix, ObjectReader reader, AnyObjectId tree) throws IOException { return new CanonicalTreeParser(pathPrefix, reader, tree); }
/** * Open an iterator over a tree. * * @param treeId * the tree to scan; must be a tree (not a treeish). * @return an iterator for the tree. * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * the input object is not a tree. * @throws java.io.IOException * the tree object is not found or cannot be read. */ protected AbstractTreeIterator openTree(AnyObjectId treeId) throws IncorrectObjectTypeException, IOException { return new CanonicalTreeParser(null, reader, treeId); }
CanonicalTreeParser oldTreeIter = new CanonicalTreeParser(); oldTreeIter.reset(reader, oldHeadTree); CanonicalTreeParser newTreeIter = new CanonicalTreeParser(); newTreeIter.reset(reader, headTree);
private CanonicalTreeParser parserFor(AnyObjectId id) throws IncorrectObjectTypeException, IOException { final CanonicalTreeParser p = new CanonicalTreeParser(); p.reset(reader, id); return p; }
/** * Back door to quickly create a subtree iterator for any subtree. * <p> * Don't use this unless you are ObjectWalk. The method is meant to be * called only once the current entry has been identified as a tree and its * identity has been converted into an ObjectId. * * @param reader * reader to load the tree data from. * @param id * ObjectId of the tree to open. * @return a new parser that walks over the current subtree. * @throws java.io.IOException * a loose object or pack file could not be read. */ public final CanonicalTreeParser createSubtreeIterator0( final ObjectReader reader, final AnyObjectId id) throws IOException { final CanonicalTreeParser p = new CanonicalTreeParser(this); p.reset(reader, id); return p; }
private AbstractTreeIterator makeIteratorFromTreeOrNull(RevTree tree) throws IncorrectObjectTypeException, IOException { if (tree != null) { CanonicalTreeParser parser = new CanonicalTreeParser(); parser.reset(reader, tree); return parser; } else return new EmptyTreeIterator(); }
BaseSearch(ProgressMonitor countingMonitor, Set<RevTree> bases, ObjectIdOwnerMap<ObjectToPack> objects, List<ObjectToPack> edges, ObjectReader or) { progress = countingMonitor; reader = or; baseTrees = bases.toArray(new ObjectId[0]); objectsMap = objects; edgeObjects = edges; alreadyProcessed = new IntSet(); treeCache = new ObjectIdOwnerMap<>(); parser = new CanonicalTreeParser(); idBuf = new MutableObjectId(); }
/** * Set the tree used by this walk for finding {@code .gitmodules}. * <p> * The root tree is not read until the first submodule is encountered by the * walk. * <p> * This method need only be called if constructing a walk manually instead of * with one of the static factory methods above. * * @param id * ID of a tree containing .gitmodules * @return this generator * @throws java.io.IOException */ public SubmoduleWalk setRootTree(AnyObjectId id) throws IOException { final CanonicalTreeParser p = new CanonicalTreeParser(); p.reset(walk.getObjectReader(), id); rootTree = p; modulesConfig = null; pathToName = null; return this; }
private static CanonicalTreeParser createParserAtPath(ObjectReader reader, AnyObjectId srcId, String prefix) throws IOException { ObjectId root = toTree(reader, srcId); if (prefix.isEmpty()) { return new CanonicalTreeParser(BINARY_R_REFS, reader, root); } String dir = RefTree.refPath(Paths.stripTrailingSeparator(prefix)); TreeWalk tw = TreeWalk.forPath(reader, dir, root); if (tw == null || !tw.isSubtree()) { return null; } ObjectId id = tw.getObjectId(0); return new CanonicalTreeParser(encode(prefix), reader, id); }
private AttributesNode findAttributes(ObjectReader reader) throws IOException { CanonicalTreeParser itr = new CanonicalTreeParser(); itr.reset(raw); if (itr.findFile(ATTRS)) { return loadAttributes(reader, itr.getEntryObjectId()); } return noAttributes(); }
CanonicalTreeParser oldTreeIter = new CanonicalTreeParser(); oldTreeIter.reset(reader, oldHead); CanonicalTreeParser newTreeIter = new CanonicalTreeParser(); newTreeIter.reset(reader, head);
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser //noinspection Duplicates try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(repository.resolve(objectId)); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser //noinspection Duplicates try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(ObjectId.fromString(objectId)); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser //noinspection Duplicates try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(repository.resolve(objectId)); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser //noinspection Duplicates try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(repository.resolve(objectId)); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser //noinspection Duplicates try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(repository.resolve(objectId)); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String objectId) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser //noinspection Duplicates try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(ObjectId.fromString(objectId)); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String ref) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser Ref head = repository.exactRef(ref); try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } } }
private static AbstractTreeIterator prepareTreeParser(Repository repository, String ref) throws IOException { // from the commit we can build the tree which allows us to construct the TreeParser Ref head = repository.exactRef(ref); try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(head.getObjectId()); RevTree tree = walk.parseTree(commit.getTree().getId()); CanonicalTreeParser treeParser = new CanonicalTreeParser(); try (ObjectReader reader = repository.newObjectReader()) { treeParser.reset(reader, tree.getId()); } walk.dispose(); return treeParser; } } }