Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.Tree


    final ObjectId cFileId2 = ow.writeBlob("c-2".getBytes());

    // Create sub-a/empty, sub-c/empty = hello.
    final ObjectId oldTree;
    {
      final Tree root = new Tree(db);
      {
        final Tree subA = root.addTree("sub-a");
        subA.addFile("empty").setId(aFileId);
        subA.setId(ow.writeTree(subA));
      }
      {
        final Tree subC = root.addTree("sub-c");
        subC.addFile("empty").setId(cFileId1);
        subC.setId(ow.writeTree(subC));
      }
      oldTree = ow.writeTree(root);
    }

    // Create sub-a/empty, sub-b/empty, sub-c/empty.
    final ObjectId newTree;
    {
      final Tree root = new Tree(db);
      {
        final Tree subA = root.addTree("sub-a");
        subA.addFile("empty").setId(aFileId);
        subA.setId(ow.writeTree(subA));
      }
      {
        final Tree subB = root.addTree("sub-b");
        subB.addFile("empty").setId(bFileId);
        subB.setId(ow.writeTree(subB));
      }
      {
        final Tree subC = root.addTree("sub-c");
        subC.addFile("empty").setId(cFileId2);
        subC.setId(ow.writeTree(subC));
      }
      newTree = ow.writeTree(root);
    }

    final TreeWalk tw = new TreeWalk(db);
View Full Code Here


    // One of our test packs contains the empty tree object. If the pack is
    // open when we create it we won't write the object file out as a loose
    // object (as it already exists in the pack).
    //
    final Repository newdb = createBareRepository();
    final Tree t = new Tree(newdb);
    t.accept(new WriteTree(trash, newdb), TreeEntry.MODIFIED_ONLY);
    assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.getId()
        .name());
    final File o = new File(new File(new File(newdb.getDirectory(),
        "objects"), "4b"), "825dc642cb6eb9a060e54bf8d69288fbee4904");
    assertTrue("Exists " + o, o.isFile());
    assertTrue("Read-only " + o, !o.canWrite());
View Full Code Here

  }

  public void test002_WriteEmptyTree2() throws IOException {
    // File shouldn't exist as it is in a test pack.
    //
    final Tree t = new Tree(db);
    t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
    assertEquals("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.getId()
        .name());
    final File o = new File(new File(
        new File(db.getDirectory(), "objects"), "4b"),
        "825dc642cb6eb9a060e54bf8d69288fbee4904");
    assertFalse("Exists " + o, o.isFile());
View Full Code Here

        "825dc642cb6eb9a060e54bf8d69288fbee4904");
    assertFalse("Exists " + o, o.isFile());
  }

  public void test003_WriteShouldBeEmptyTree() throws IOException {
    final Tree t = new Tree(db);
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    t.addFile("should-be-empty").setId(emptyId);
    t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
    assertEquals("7bb943559a305bdd6bdee2cef6e5df2413c3d30a", t.getId()
        .name());

    File o;
    o = new File(new File(new File(db.getDirectory(), "objects"), "7b"),
        "b943559a305bdd6bdee2cef6e5df2413c3d30a");
View Full Code Here

      assertTrue(ioe.getMessage().indexOf(badvers) > 0);
    }
  }

  public void test009_CreateCommitOldFormat() throws IOException {
    final Tree t = new Tree(db);
    final FileTreeEntry f = t.addFile("i-am-a-file");
    writeTrashFile(f.getName(), "and this is the data in me\n");
    t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
    assertEquals(ObjectId.fromString("00b1f73724f493096d1ffa0b0f1f1482dbb8c936"),
        t.getTreeId());

    final Commit c = new Commit(db);
    c.setAuthor(new PersonIdent(author, 1154236443000L, -4 * 60));
    c.setCommitter(new PersonIdent(committer, 1154236443000L, -4 * 60));
    c.setMessage("A Commit\n");
    c.setTree(t);
    assertEquals(t.getTreeId(), c.getTreeId());
    c.commit();
    final ObjectId cmtid = ObjectId.fromString(
        "803aec4aba175e8ab1d666873c984c0308179099");
    assertEquals(cmtid, c.getCommitId());

View Full Code Here

    assertEquals(c.getCommitter(), c2.getCommitter());
  }

  public void test012_SubtreeExternalSorting() throws IOException {
    final ObjectId emptyBlob = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tree t = new Tree(db);
    final FileTreeEntry e0 = t.addFile("a-");
    final FileTreeEntry e1 = t.addFile("a-b");
    final FileTreeEntry e2 = t.addFile("a/b");
    final FileTreeEntry e3 = t.addFile("a=");
    final FileTreeEntry e4 = t.addFile("a=b");

    e0.setId(emptyBlob);
    e1.setId(emptyBlob);
    e2.setId(emptyBlob);
    e3.setId(emptyBlob);
    e4.setId(emptyBlob);

    t.accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
    assertEquals(ObjectId.fromString("b47a8f0a4190f7572e11212769090523e23eb1ea"),
        t.getId());
  }
View Full Code Here

    // We do not repeat the plain tag test for other object types
  }

  public void test021_createTreeTag() throws IOException {
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tree almostEmptyTree = new Tree(db);
    almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
    final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
    final Tag t = new Tag(db);
    t.setObjId(almostEmptyTreeId);
    t.setType("tree");
    t.setTag("test021");
View Full Code Here

    assertEquals("417c01c8795a35b8e835113a85a5c0c1c77f67fb", mapTag.getObjId().name());
  }

  public void test022_createCommitTag() throws IOException {
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tree almostEmptyTree = new Tree(db);
    almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
    final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
    final Commit almostEmptyCommit = new Commit(db);
    almostEmptyCommit.setAuthor(new PersonIdent(author, 1154236443000L, -2 * 60)); // not exactly the same
    almostEmptyCommit.setCommitter(new PersonIdent(author, 1154236443000L, -2 * 60));
    almostEmptyCommit.setMessage("test022\n");
 
View Full Code Here

    assertEquals("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.getObjId().name());
  }

  public void test023_createCommitNonAnullii() throws IOException {
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tree almostEmptyTree = new Tree(db);
    almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
    final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
    Commit commit = new Commit(db);
    commit.setTreeId(almostEmptyTreeId);
    commit.setAuthor(new PersonIdent("Joe H\u00e4cker","joe@example.com",4294967295000L,60));
    commit.setCommitter(new PersonIdent("Joe Hacker","joe2@example.com",4294967295000L,60));
View Full Code Here

    assertEquals(commit.getMessage(), loadedCommit.getMessage());
  }

  public void test024_createCommitNonAscii() throws IOException {
    final ObjectId emptyId = new ObjectWriter(db).writeBlob(new byte[0]);
    final Tree almostEmptyTree = new Tree(db);
    almostEmptyTree.addEntry(new FileTreeEntry(almostEmptyTree, emptyId, "empty".getBytes(), false));
    final ObjectId almostEmptyTreeId = new ObjectWriter(db).writeTree(almostEmptyTree);
    Commit commit = new Commit(db);
    commit.setTreeId(almostEmptyTreeId);
    commit.setAuthor(new PersonIdent("Joe H\u00e4cker","joe@example.com",4294967295000L,60));
    commit.setCommitter(new PersonIdent("Joe Hacker","joe2@example.com",4294967295000L,60));
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.Tree

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.