Package org.eclipse.jgit.revwalk

Examples of org.eclipse.jgit.revwalk.RevBlob


   */
  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();
View Full Code Here


   */
  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();
View Full Code Here

import org.junit.Test;

public class GcPackRefsTest extends GcTestCase {
  @Test
  public void looseRefPacked() throws Exception {
    RevBlob a = tr.blob("a");
    tr.lightweightTag("t", a);

    gc.packRefs();
    assertSame(repo.getRef("t").getStorage(), Storage.PACKED);
  }
View Full Code Here

    assertSame(repo.getRef("t").getStorage(), Storage.PACKED);
  }

  @Test
  public void concurrentOnlyOneWritesPackedRefs() throws Exception {
    RevBlob a = tr.blob("a");
    tr.lightweightTag("t", a);

    final CyclicBarrier syncPoint = new CyclicBarrier(2);

    Callable<Integer> packRefs = new Callable<Integer>() {
View Full Code Here

  }

  @Test
  public void whileRefLockedRefNotPackedNoError()
      throws Exception {
    RevBlob a = tr.blob("a");
    tr.lightweightTag("t1", a);
    tr.lightweightTag("t2", a);
    LockFile refLock = new LockFile(new File(repo.getDirectory(),
        "refs/tags/t1"), repo.getFS());
    try {
View Full Code Here

  }

  @Test
  public void whileRefUpdatedRefUpdateSucceeds()
      throws Exception {
    RevBlob a = tr.blob("a");
    tr.lightweightTag("t", a);
    final RevBlob b = tr.blob("b");

    final CyclicBarrier refUpdateLockedRef = new CyclicBarrier(2);
    final CyclicBarrier packRefsDone = new CyclicBarrier(2);
    ExecutorService pool = Executors.newFixedThreadPool(2);
    try {
View Full Code Here

          return valueOf(1);
        }
      }
    }

    RevBlob a = tr.blob("a");
    tr.lightweightTag("t", a);

    ExecutorService pool = Executors.newFixedThreadPool(2);
    try {
      DoRepack repack1 = new DoRepack();
View Full Code Here

  @Test
  public void testWhole_SmallObject() throws Exception {
    final int type = Constants.OBJ_BLOB;
    byte[] data = getRng().nextBytes(300);
    RevBlob id = tr.blob(data);
    tr.branch("master").commit().add("A", id).create();
    tr.packAndPrune();
    assertTrue("has blob", wc.has(id));

    ObjectLoader ol = wc.open(id);
View Full Code Here

  @Test
  public void testWhole_LargeObject() throws Exception {
    final int type = Constants.OBJ_BLOB;
    byte[] data = getRng().nextBytes(streamThreshold + 5);
    RevBlob id = tr.blob(data);
    tr.branch("master").commit().add("A", id).create();
    tr.packAndPrune();
    assertTrue("has blob", wc.has(id));

    ObjectLoader ol = wc.open(id);
    assertNotNull("created loader", ol);
    assertEquals(type, ol.getType());
    assertEquals(data.length, ol.getSize());
    assertTrue("is large", ol.isLarge());
    try {
      ol.getCachedBytes();
      fail("Should have thrown LargeObjectException");
    } catch (LargeObjectException tooBig) {
      assertEquals(MessageFormat.format(
          JGitText.get().largeObjectException, id.name()), tooBig
          .getMessage());
    }

    ObjectStream in = ol.openStream();
    assertNotNull("have stream", in);
View Full Code Here

    // commit something on the test branch
    writeTrashFile("Test.txt", "Some change");
    git.add().addFilepattern("Test.txt").call();
    git.commit().setMessage("Second commit").call();
    RevBlob blob = tr.blob("blob-not-in-master-branch");
    git.tag().setName("tag-for-blob").setObjectId(blob).call();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.revwalk.RevBlob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.