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); } }
/** * Get the last modified time of this entry. * * @return last modified time of this file, in milliseconds since the epoch * (Jan 1, 1970 UTC). */ public long getEntryLastModified() { return current().getLastModified(); }
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(); }
CanonicalTreeParser oldTreeIter = new CanonicalTreeParser(); oldTreeIter.reset(reader, oldHeadTree); CanonicalTreeParser newTreeIter = new CanonicalTreeParser(); newTreeIter.reset(reader, headTree);
private void addTree(TreeWalk tw, ObjectId id) throws MissingObjectException, IncorrectObjectTypeException, IOException { if (id == null) tw.addTree(new EmptyTreeIterator()); else tw.addTree(id); }
/** * Create a new iterator for the current entry's subtree. * <p> * The parent reference of the iterator must be <code>this</code>, otherwise * the caller would not be able to exit out of the subtree iterator * correctly and return to continue walking <code>this</code>. * * @return a new iterator that walks over the current subtree. * @since 5.0 */ protected AbstractTreeIterator enterSubtree() { return new FileTreeIterator(this, ((FileEntry) current()).getFile(), fs, fileModeStrategy); }
/** * Is the current entry a subtree returned after its children? * * @return true if the current node is a tree that has been returned after * its children were already processed. * @see #isPostOrderTraversal() */ public boolean isPostChildren() { return postChildren && isSubtree(); }
private static CanonicalTreeParser enterTree(CanonicalTreeParser p, ObjectReader reader) throws IOException { p = p.createSubtreeIterator(reader); return p.eof() ? p.next() : p; }
/** {@inheritDoc} */ @Override public boolean include(TreeWalk tw) throws MissingObjectException, IncorrectObjectTypeException, IOException { WorkingTreeIterator i = tw.getTree(index, WorkingTreeIterator.class); return i == null || !i.isEntryIgnored(); }
/** {@inheritDoc} */ @Override public AbstractTreeIterator createSubtreeIterator(ObjectReader reader) throws IncorrectObjectTypeException, IOException { return new EmptyTreeIterator(this); }
private static boolean curElementHasPeelSuffix(AbstractTreeIterator itr) { int n = itr.getEntryPathLength(); byte[] c = itr.getEntryPathBuffer(); return n > 2 && c[n - 2] == ' ' && c[n - 1] == '^'; }
private boolean isDirectoryIgnored(String pathRel) throws IOException { final int pOff = 0 < pathOffset ? pathOffset - 1 : pathOffset; final String base = TreeWalk.pathOf(this.path, 0, pOff); final String pathAbs = concatPath(base, pathRel); return isDirectoryIgnored(pathRel, pathAbs); }
int pathCompare(AbstractTreeIterator p, int pMode) { // Its common when we are a subtree for both parents to match; // when this happens everything in path[0..cPos] is known to // be equal and does not require evaluation again. // int cPos = alreadyMatch(this, p); return pathCompare(p.path, cPos, p.pathLen, pMode, cPos); }
/** {@inheritDoc} */ @Override protected byte[] idSubmodule(Entry e) { return idSubmodule(getDirectory(), e); }
/** * Determine if the current entry path is ignored by an ignore rule. * * @return true if the entry was ignored by an ignore rule file. * @throws java.io.IOException * a relevant ignore rule file exists but cannot be read. */ public boolean isEntryIgnored() throws IOException { return isEntryIgnored(pathLen); }
/** {@inheritDoc} */ @Override public void back(int delta) throws CorruptObjectException { ptr -= delta; parseEntry(); }
/** * Create a new iterator with no parent. * * @param options * working tree options to be used */ protected WorkingTreeIterator(WorkingTreeOptions options) { super(); state = new IteratorState(options); }
/** * Create a new iterator as though the current entry were a subtree. * * @return a new empty tree iterator. */ public EmptyTreeIterator createEmptyTreeIterator() { return new EmptyTreeIterator(this); }