Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCacheEntry


  @Test
  public void testPathsResetWithRef() throws Exception {
    setupRepository();

    DirCacheEntry preReset = DirCache.read(db.getIndexFile(), db.getFS())
        .getEntry(indexFile.getName());
    assertNotNull(preReset);

    git.add().addFilepattern(untrackedFile.getName()).call();
View Full Code Here


    git.add().addFilepattern("a.txt").call();
    // Should assume an empty tree, like in C Git 1.8.2
    git.reset().addPath("a.txt").call();

    DirCache cache = db.readDirCache();
    DirCacheEntry aEntry = cache.getEntry("a.txt");
    assertNull(aEntry);
  }
View Full Code Here

    writeTrashFile("a.txt", "modified");
    // should use default mode MIXED
    git.reset().call();

    DirCache cache = db.readDirCache();
    DirCacheEntry aEntry = cache.getEntry("a.txt");
    assertNull(aEntry);
    assertEquals("modified", read("a.txt"));
  }
View Full Code Here

    setupRepository();
    String tagName = "initialtag";
    git.tag().setName(tagName).setObjectId(secondCommit)
        .setMessage("message").call();

    DirCacheEntry preReset = DirCache.read(db.getIndexFile(), db.getFS())
        .getEntry(indexFile.getName());
    assertNotNull(preReset);

    git.add().addFilepattern(untrackedFile.getName()).call();
View Full Code Here

    git.add().addFilepattern("a.txt").call();
    // Should assume an empty tree, like in C Git 1.8.2
    git.reset().setMode(ResetType.HARD).call();

    DirCache cache = db.readDirCache();
    DirCacheEntry aEntry = cache.getEntry("a.txt");
    assertNull(aEntry);
    assertFalse(fileA.exists());
    assertNull(db.resolve(Constants.HEAD));
  }
View Full Code Here

      throws IOException {
    FileInputStream inputStream = new FileInputStream(file);
    ObjectId id = newObjectInserter.insert(
        Constants.OBJ_BLOB, file.length(), inputStream);
    inputStream.close();
    DirCacheEntry entry = new DirCacheEntry(path, stage);
    entry.setObjectId(id);
    entry.setFileMode(FileMode.REGULAR_FILE);
    entry.setLastModified(file.lastModified());
    entry.setLength((int) file.length());

    builder.add(entry);
    return entry;
  }
View Full Code Here

    return entry;
  }

  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

    final DirCache tree0 = DirCache.newInCore();
    final DirCacheBuilder b0 = tree0.builder();
    ObjectReader or = db.newObjectReader();
    ObjectInserter oi = db.newObjectInserter();

    DirCacheEntry aDotB = createEntry("a.b", EXECUTABLE_FILE);
    b0.add(aDotB);
    DirCacheEntry aSlashB = createEntry("a/b", REGULAR_FILE);
    b0.add(aSlashB);
    DirCacheEntry aSlashCSlashD = createEntry("a/c/d", REGULAR_FILE);
    b0.add(aSlashCSlashD);
    DirCacheEntry aZeroB = createEntry("a0b", SYMLINK);
    b0.add(aZeroB);
    b0.finish();
    assertEquals(4, tree0.getEntryCount());
    ObjectId tree = tree0.writeTree(oi);

    // Find the directories that were implicitly created above.
    TreeWalk tw = new TreeWalk(or);
    tw.addTree(tree);
    ObjectId a = null;
    ObjectId aSlashC = null;
    while (tw.next()) {
      if (tw.getPathString().equals("a")) {
        a = tw.getObjectId(0);
        tw.enterSubtree();
        while (tw.next()) {
          if (tw.getPathString().equals("a/c")) {
            aSlashC = tw.getObjectId(0);
            break;
          }
        }
        break;
      }
    }

    assertEquals(a, TreeWalk.forPath(or, "a", tree).getObjectId(0));
    assertEquals(a, TreeWalk.forPath(or, "a/", tree).getObjectId(0));
    assertEquals(null, TreeWalk.forPath(or, "/a", tree));
    assertEquals(null, TreeWalk.forPath(or, "/a/", tree));

    assertEquals(aDotB.getObjectId(), TreeWalk.forPath(or, "a.b", tree)
        .getObjectId(0));
    assertEquals(null, TreeWalk.forPath(or, "/a.b", tree));
    assertEquals(null, TreeWalk.forPath(or, "/a.b/", tree));
    assertEquals(aDotB.getObjectId(), TreeWalk.forPath(or, "a.b/", tree)
        .getObjectId(0));

    assertEquals(aZeroB.getObjectId(), TreeWalk.forPath(or, "a0b", tree)
        .getObjectId(0));

    assertEquals(aSlashB.getObjectId(), TreeWalk.forPath(or, "a/b", tree)
        .getObjectId(0));
    assertEquals(aSlashB.getObjectId(), TreeWalk.forPath(or, "b", a)
View Full Code Here

        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

            AbstractTreeIterator.class);
        if (cIter == null)
          // Not in commit, don't create untracked
          continue;

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

        FileTreeIterator fIter = walk
            .getTree(1, FileTreeIterator.class);
        if (fIter != null) {
          if (fIter.isModified(entry, true, reader)) {
            // file exists and is dirty
            throw new CheckoutConflictException(
                entry.getPathString());
          }
        }

        checkoutPath(entry, reader);
      }
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.