Example usage for org.eclipse.jgit.revwalk RevWalk lookupBlob

List of usage examples for org.eclipse.jgit.revwalk RevWalk lookupBlob

Introduction

In this page you can find the example usage for org.eclipse.jgit.revwalk RevWalk lookupBlob.

Prototype

@NonNull
public RevBlob lookupBlob(AnyObjectId id) 

Source Link

Document

Locate a reference to a blob without loading it.

Usage

From source file:com.gitblit.utils.JGitUtils.java

License:Apache License

/**
 * Gets the raw byte content of the specified blob object.
 *
 * @param repository/* w  ww  .ja va2 s.co m*/
 * @param objectId
 * @return byte [] blob content
 */
public static byte[] getByteContent(Repository repository, String objectId) {
    RevWalk rw = new RevWalk(repository);
    byte[] content = null;
    try {
        RevBlob blob = rw.lookupBlob(ObjectId.fromString(objectId));
        ObjectLoader ldr = repository.open(blob.getId(), Constants.OBJ_BLOB);
        content = ldr.getCachedBytes();
    } catch (Throwable t) {
        error(t, repository, "{0} can't find blob {1}", objectId);
    } finally {
        rw.dispose();
    }
    return content;
}