Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheBuilder


    final DirCache treeB = db.readDirCache();
    final DirCache treeO = db.readDirCache();
    final DirCache treeP = db.readDirCache();
    final DirCache treeT = db.readDirCache();
    {
      final DirCacheBuilder b = treeB.builder();
      final DirCacheBuilder o = treeO.builder();
      final DirCacheBuilder p = treeP.builder();
      final DirCacheBuilder t = treeT.builder();

      b.add(createEntry("a", FileMode.REGULAR_FILE));

      o.add(createEntry("a", FileMode.REGULAR_FILE));
      o.add(createEntry("o", FileMode.REGULAR_FILE));

      p.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
      p.add(createEntry("p-fail", FileMode.REGULAR_FILE));

      t.add(createEntry("a", FileMode.REGULAR_FILE));
      t.add(createEntry("t", FileMode.REGULAR_FILE));

      b.finish();
      o.finish();
      p.finish();
      t.finish();
    }

    final ObjectInserter ow = db.newObjectInserter();
    final ObjectId B = commit(ow, treeB, new ObjectId[] {});
    final ObjectId O = commit(ow, treeO, new ObjectId[] { B });
View Full Code Here


    //
    final DirCache treeB = db.readDirCache();
    final DirCache treeP = db.readDirCache();
    final DirCache treeT = db.readDirCache();
    {
      final DirCacheBuilder b = treeB.builder();
      final DirCacheBuilder p = treeP.builder();
      final DirCacheBuilder t = treeT.builder();

      b.add(createEntry("a", FileMode.REGULAR_FILE));

      p.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
      p.add(createEntry("p-fail", FileMode.REGULAR_FILE));

      t.add(createEntry("a", FileMode.REGULAR_FILE, "q"));
      t.add(createEntry("p-fail", FileMode.REGULAR_FILE));
      t.add(createEntry("t", FileMode.REGULAR_FILE));

      b.finish();
      p.finish();
      t.finish();
    }

    final ObjectInserter ow = db.newObjectInserter();
    final ObjectId B = commit(ow, treeB, new ObjectId[] {});
    final ObjectId P = commit(ow, treeP, new ObjectId[] { B });
View Full Code Here

  private void resetIndex(RevTree tree) throws IOException {
    DirCache dc = repo.lockDirCache();
    TreeWalk walk = null;
    try {
      DirCacheBuilder builder = dc.builder();

      walk = new TreeWalk(repo);
      walk.addTree(tree);
      walk.addTree(new DirCacheIterator(dc));
      walk.setRecursive(true);

      while (walk.next()) {
        AbstractTreeIterator cIter = walk.getTree(0, AbstractTreeIterator.class);
        if (cIter == null) {
          // Not in commit, don't add to new index
          continue;
        }

        final DirCacheEntry entry = new DirCacheEntry(walk.getRawPath());
        entry.setFileMode(cIter.getEntryFileMode());
        entry.setObjectIdFromRaw(cIter.idBuffer(), cIter.idOffset());

        DirCacheIterator dcIter = walk.getTree(1, DirCacheIterator.class);
        if (dcIter != null && dcIter.idEqual(cIter)) {
          DirCacheEntry indexEntry = dcIter.getDirCacheEntry();
          entry.setLastModified(indexEntry.getLastModified());
          entry.setLength(indexEntry.getLength());
        }

        builder.add(entry);
      }

      builder.commit();
    } finally {
      dc.unlock();
      if (walk != null)
        walk.release();
    }
View Full Code Here

      throws IOException {
    final DirCacheEntry e = new DirCacheEntry(path);
    e.setFileMode(fileMode);
    e.setObjectId(objectId);

    final DirCacheBuilder dirCacheBuilder = repository.lockDirCache().builder();
    dirCacheBuilder.add(e);
    dirCacheBuilder.commit();
  }
View Full Code Here

   * @return reference to the tree specified by the entry list.
   * @throws Exception
   */
  public RevTree tree(final DirCacheEntry... entries) throws Exception {
    final DirCache dc = DirCache.newInCore();
    final DirCacheBuilder b = dc.builder();
    for (final DirCacheEntry e : entries)
      b.add(e);
    b.finish();
    ObjectId root;
    try {
      root = dc.writeTree(inserter);
      inserter.flush();
    } finally {
View Full Code Here

  }

  public void testNoPostOrder() throws Exception {
    final DirCache tree = db.readDirCache();
    {
      final DirCacheBuilder b = tree.builder();

      b.add(makeFile("a"));
      b.add(makeFile("b/c"));
      b.add(makeFile("b/d"));
      b.add(makeFile("q"));

      b.finish();
      assertEquals(4, tree.getEntryCount());
    }

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

  }

  public void testWithPostOrder_EnterSubtree() throws Exception {
    final DirCache tree = db.readDirCache();
    {
      final DirCacheBuilder b = tree.builder();

      b.add(makeFile("a"));
      b.add(makeFile("b/c"));
      b.add(makeFile("b/d"));
      b.add(makeFile("q"));

      b.finish();
      assertEquals(4, tree.getEntryCount());
    }

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

  }

  public void testWithPostOrder_NoEnterSubtree() throws Exception {
    final DirCache tree = db.readDirCache();
    {
      final DirCacheBuilder b = tree.builder();

      b.add(makeFile("a"));
      b.add(makeFile("b/c"));
      b.add(makeFile("b/d"));
      b.add(makeFile("q"));

      b.finish();
      assertEquals(4, tree.getEntryCount());
    }

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

  public void testNoDF_NoGap() throws Exception {
    final DirCache tree0 = db.readDirCache();
    final DirCache tree1 = db.readDirCache();
    {
      final DirCacheBuilder b0 = tree0.builder();
      final DirCacheBuilder b1 = tree1.builder();

      b0.add(makeEntry("a", REGULAR_FILE));
      b0.add(makeEntry("a.b", EXECUTABLE_FILE));
      b1.add(makeEntry("a/b", REGULAR_FILE));
      b0.add(makeEntry("a0b", SYMLINK));

      b0.finish();
      b1.finish();
      assertEquals(3, tree0.getEntryCount());
      assertEquals(1, tree1.getEntryCount());
    }

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

  public void testDF_NoGap() throws Exception {
    final DirCache tree0 = db.readDirCache();
    final DirCache tree1 = db.readDirCache();
    {
      final DirCacheBuilder b0 = tree0.builder();
      final DirCacheBuilder b1 = tree1.builder();

      b0.add(makeEntry("a", REGULAR_FILE));
      b0.add(makeEntry("a.b", EXECUTABLE_FILE));
      b1.add(makeEntry("a/b", REGULAR_FILE));
      b0.add(makeEntry("a0b", SYMLINK));

      b0.finish();
      b1.finish();
      assertEquals(3, tree0.getEntryCount());
      assertEquals(1, tree1.getEntryCount());
    }

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

TOP

Related Classes of org.eclipse.jgit.dircache.DirCacheBuilder

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.