Example usage for org.eclipse.jgit.lib MutableObjectId fromObjectId

List of usage examples for org.eclipse.jgit.lib MutableObjectId fromObjectId

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib MutableObjectId fromObjectId.

Prototype

public void fromObjectId(AnyObjectId src) 

Source Link

Document

Copy an ObjectId into this mutable buffer.

Usage

From source file:com.tasktop.c2c.server.scm.service.GitBrowseUtil.java

License:Open Source License

private static TreeWalk getTreeOnPath(MutableObjectId id, Repository repo, ObjectId rev, String path)
        throws MissingObjectException, IOException {

    RevTree tree = new RevWalk(repo).parseTree(rev);

    TreeWalk tw = new TreeWalk(repo);
    tw.reset(tree);//from w  w  w.j  a v a 2  s.c o m
    tw.setRecursive(false);

    if (path == null || path.isEmpty() || "/".equals(path)) {
        id.fromObjectId(tree.getId());
        return tw;
    }

    PathFilter f = PathFilter.create(path);
    tw.setFilter(f);

    while (tw.next()) {
        if (f.isDone(tw)) {
            id.fromObjectId(tw.getObjectId(0));
            if (tw.isSubtree()) {
                tw.enterSubtree();
                return tw;
            } else {
                throw new MissingObjectException(tw.getObjectId(0), Constants.OBJ_TREE);
            }

        } else if (tw.isSubtree()) {
            tw.enterSubtree();
        }
    }
    return null;

}