Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheEntry


        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);
      }
View Full Code Here


    treeWalk.addTree(dci);

    final ObjectReader r = treeWalk.getObjectReader();
    DirCacheEditor editor = dc.editor();
    while (treeWalk.next()) {
      DirCacheEntry entry = dci.getDirCacheEntry();
      // Only add one edit per path
      if (entry != null && entry.getStage() > DirCacheEntry.STAGE_1)
        continue;
      editor.add(new PathEdit(treeWalk.getPathString()) {
        public void apply(DirCacheEntry ent) {
          int stage = ent.getStage();
          if (stage > DirCacheEntry.STAGE_0) {
View Full Code Here

    git.add().addFilepattern("b").call();
    git.commit().setMessage("master commit").call();

    // Simulate a failed merge of branch into master
    DirCacheBuilder builder = db.lockDirCache().builder();
    DirCacheEntry entry = createEntry("a", FileMode.REGULAR_FILE, 0,
        "content");
    builder.add(entry);
    entry = createEntry("b", FileMode.REGULAR_FILE, 2,
        "second file content - master");
    builder.add(entry);
View Full Code Here

  private void verifyStageState(StageState expected, int... stages)
      throws IOException {
    DirCacheBuilder builder = db.lockDirCache().builder();
    for (int stage : stages) {
      DirCacheEntry entry = createEntry("a", FileMode.REGULAR_FILE,
          stage, "content");
      builder.add(entry);
    }
    builder.commit();
View Full Code Here

      throw new IOException("could not commit");
  }

  private void assumeUnchanged(String path) throws IOException {
    final DirCache dirc = db.lockDirCache();
    final DirCacheEntry ent = dirc.getEntry(path);
    if (ent != null)
      ent.setAssumeValid(true);
    dirc.write();
    if (!dirc.commit())
      throw new IOException("could not commit");
  }
View Full Code Here

    git.add().addFilepattern(path).call();
    git.add().addFilepattern(path2).call();
    git.commit().setMessage("commit").call();

    DirCache dc = db.readDirCache();
    DirCacheEntry entry = dc.getEntry(path);
    DirCacheEntry entry2 = dc.getEntry(path);

    assertTrue("last modified shall not be zero!",
        entry.getLastModified() != 0);

    assertTrue("last modified shall not be zero!",
        entry2.getLastModified() != 0);

    writeTrashFile(path, "new content");
    git.add().addFilepattern(path).call();
    git.commit().setMessage("commit2").call();

    dc = db.readDirCache();
    entry = dc.getEntry(path);
    entry2 = dc.getEntry(path);

    assertTrue("last modified shall not be zero!",
        entry.getLastModified() != 0);

    assertTrue("last modified shall not be zero!",
        entry2.getLastModified() != 0);
  }
View Full Code Here

    git.add().addFilepattern(path).call();
    git.commit().setMessage("commit").call();

    DirCache dc = db.readDirCache();
    DirCacheEntry entry = dc.getEntry(path);

    long masterLastMod = entry.getLastModified();

    git.checkout().setCreateBranch(true).setName("side").call();

    Thread.sleep(10);
    String path2 = "file2";
    writeTrashFile(path2, "side content");
    git.add().addFilepattern(path2).call();
    git.commit().setMessage("commit").call();

    dc = db.readDirCache();
    entry = dc.getEntry(path);

    long sideLastMode = entry.getLastModified();

    Thread.sleep(2000);

    writeTrashFile(path, "uncommitted content");
    git.checkout().setName("master").call();

    dc = db.readDirCache();
    entry = dc.getEntry(path);

    assertTrue("shall have equal mod time!", masterLastMod == sideLastMode);
    assertTrue("shall not equal master timestamp!",
        entry.getLastModified() == masterLastMod);

  }
View Full Code Here

      throws Exception {
    DirCache index = db.lockDirCache();
    DirCacheBuilder builder = index.builder();
    addUnmergedEntry("unmerged1", builder);
    addUnmergedEntry("unmerged2", builder);
    DirCacheEntry other = new DirCacheEntry("other");
    other.setFileMode(FileMode.REGULAR_FILE);
    builder.add(other);
    builder.commit();

    writeTrashFile("unmerged1", "unmerged1 data");
    writeTrashFile("unmerged2", "unmerged2 data");
View Full Code Here

    assertEquals(FileMode.REGULAR_FILE, walk.getFileMode(0));
    walk.release();
  }

  private static void addUnmergedEntry(String file, DirCacheBuilder builder) {
    DirCacheEntry stage1 = new DirCacheEntry(file, DirCacheEntry.STAGE_1);
    DirCacheEntry stage2 = new DirCacheEntry(file, DirCacheEntry.STAGE_2);
    DirCacheEntry stage3 = new DirCacheEntry(file, DirCacheEntry.STAGE_3);
    stage1.setFileMode(FileMode.REGULAR_FILE);
    stage2.setFileMode(FileMode.REGULAR_FILE);
    stage3.setFileMode(FileMode.REGULAR_FILE);
    builder.add(stage1);
    builder.add(stage2);
    builder.add(stage3);
  }
View Full Code Here

    WorkingTreeIterator wi = workingTree(tw);
    String path = tw.getPathString();

    DirCacheIterator di = tw.getTree(dirCache, DirCacheIterator.class);
    if (di != null) {
      DirCacheEntry dce = di.getDirCacheEntry();
      if (dce != null) {
        if (dce.isAssumeValid())
          return false;
        // Never filter index entries with a stage different from 0
        if (dce.getStage() != 0)
          return true;
      }
    }

    if (!tw.isPostOrderTraversal()) {
View Full Code Here

TOP

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

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.