Example usage for org.eclipse.jgit.treewalk CanonicalTreeParser next

List of usage examples for org.eclipse.jgit.treewalk CanonicalTreeParser next

Introduction

In this page you can find the example usage for org.eclipse.jgit.treewalk CanonicalTreeParser next.

Prototype

@Override
public void next(int delta) 

Source Link

Usage

From source file:de.codesourcery.gittimelapse.GitHelper.java

License:Apache License

protected void readFile(String path, PathFilter filter, RevCommit current, final ByteArrayOutputStream buffer)
        throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException {
    final String strippedPath = stripRepoBaseDir(path);
    final ITreeVisitor visitor = new ITreeVisitor() {

        @Override// w  ww.  j a  va  2 s .  c o m
        public boolean visit(TreeWalk treeWalk) throws MissingObjectException, IOException {
            final CanonicalTreeParser parser = treeWalk.getTree(0, CanonicalTreeParser.class);
            while (!parser.eof()) {
                if (parser.getEntryPathString().equals(strippedPath)) {
                    ObjectLoader loader = repository.open(parser.getEntryObjectId());
                    buffer.write(loader.getBytes());
                }
                parser.next(1);
            }
            return true;
        }
    };
    visitCommitTree(path, filter, current, visitor);
}