Examples of DirCacheEditor


Examples of org.eclipse.jgit.dircache.DirCacheEditor

  @Test
  public void testOneOnly() throws IOException {
    DirCache dc1 = DirCache.newInCore();
    DirCache dc2 = DirCache.newInCore();
    DirCacheEditor editor = dc1.editor();
    editor.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
    editor.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

  @Test
  public void testTwoSame() throws IOException {
    DirCache dc1 = DirCache.newInCore();
    DirCache dc2 = DirCache.newInCore();
    DirCacheEditor ed1 = dc1.editor();
    ed1.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
    ed1.finish();
    DirCacheEditor ed2 = dc2.editor();
    ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
    ed2.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

  @Test
  public void testTwoSameDifferByAssumeValid() throws IOException {
    DirCache dc1 = DirCache.newInCore();
    DirCache dc2 = DirCache.newInCore();
    DirCacheEditor ed1 = dc1.editor();
    ed1.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, false));
    ed1.finish();
    DirCacheEditor ed2 = dc2.editor();
    ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, true));
    ed2.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

  @Test
  public void testTwoSameSameAssumeValidDifferentContent()
      throws IOException {
    DirCache dc1 = DirCache.newInCore();
    DirCache dc2 = DirCache.newInCore();
    DirCacheEditor ed1 = dc1.editor();
    ed1.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("a"), 1, true));
    ed1.finish();
    DirCacheEditor ed2 = dc2.editor();
    ed2.add(new AddEdit("a/a", FileMode.REGULAR_FILE, id("b"), 1, true));
    ed2.finish();

    TreeWalk tw = new TreeWalk(db);
    tw.setRecursive(true);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    }
  }

  TreeWalk fakeWalk(final String path) throws IOException {
    DirCache dc = DirCache.newInCore();
    DirCacheEditor dce = dc.editor();
    dce.add(new DirCacheEditor.PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.REGULAR_FILE);
      }
    });
    dce.finish();

    TreeWalk ret = new TreeWalk((ObjectReader) null);
    ret.reset();
    ret.setRecursive(true);
    ret.addTree(new DirCacheIterator(dc));
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

        }
      });
    }

    public CommitBuilder edit(PathEdit edit) {
      DirCacheEditor e = tree.editor();
      e.add(edit);
      e.finish();
      return this;
    }
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

      e.finish();
      return this;
    }

    public CommitBuilder rm(String path) {
      DirCacheEditor e = tree.editor();
      e.add(new DeletePath(path));
      e.add(new DeleteTree(path));
      e.finish();
      return this;
    }
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

          untrackedCommit = inserter.insert(builder);
        }

        // Commit working tree changes
        if (!wtEdits.isEmpty() || !wtDeletes.isEmpty()) {
          DirCacheEditor editor = cache.editor();
          for (PathEdit edit : wtEdits)
            editor.add(edit);
          for (String path : wtDeletes)
            editor.add(new DeletePath(path));
          editor.finish();
        }
        builder.setParentId(headCommit);
        builder.addParentId(indexCommit);
        if (untrackedCommit != null)
          builder.addParentId(untrackedCommit);
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    writeTrashFile("file.txt", "content");
    git.add().addFilepattern("file.txt").call();
    final RevCommit id = git.commit().setMessage("create file").call();
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    Git.cloneRepository().setURI(db.getDirectory().toURI().toString())
        .setDirectory(new File(db.getWorkTree(), path)).call()
        .getRepository().close();
View Full Code Here

Examples of org.eclipse.jgit.dircache.DirCacheEditor

    writeTrashFile("file.txt", "content");
    git.add().addFilepattern("file.txt").call();
    final RevCommit id = git.commit().setMessage("create file").call();
    final String path = "sub";
    DirCache cache = db.lockDirCache();
    DirCacheEditor editor = cache.editor();
    editor.add(new PathEdit(path) {

      public void apply(DirCacheEntry ent) {
        ent.setFileMode(FileMode.GITLINK);
        ent.setObjectId(id);
      }
    });
    editor.commit();

    File submoduleRoot = new File(db.getWorkTree(), path);
    assertTrue(submoduleRoot.mkdir());
    assertTrue(new File(submoduleRoot, Constants.DOT_GIT).mkdir());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.