Package org.eclipse.jgit.dircache

Examples of org.eclipse.jgit.dircache.DirCache


    assertEquals(RepositoryState.MERGING, db.getRepositoryState());
    assertStageOneToThree(FILE1);
  }

  private void assertStageOneToThree(String name) throws Exception {
    DirCache cache = DirCache.read(db.getIndexFile(), db.getFS());
    int i = cache.findEntry(name);
    DirCacheEntry stage1 = cache.getEntry(i);
    DirCacheEntry stage2 = cache.getEntry(i + 1);
    DirCacheEntry stage3 = cache.getEntry(i + 2);

    assertEquals(DirCacheEntry.STAGE_1, stage1.getStage());
    assertEquals(DirCacheEntry.STAGE_2, stage2.getStage());
    assertEquals(DirCacheEntry.STAGE_3, stage3.getStage());
  }
View Full Code Here


    db = createWorkRepository();
  }

  @Test
  public void testEmpty() throws IOException {
    DirCache dc1 = DirCache.newInCore();
    DirCache dc2 = DirCache.newInCore();
    TreeWalk tw = new TreeWalk(db);
    tw.addTree(new DirCacheIterator(dc1));
    tw.addTree(new DirCacheIterator(dc2));
    assertFalse(tw.next());
  }
View Full Code Here

    return db.newObjectInserter().idFor(Constants.OBJ_BLOB, bytes);
  }

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

    assertFalse(tw.next());
  }

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

    assertFalse(tw.next());
  }

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

  }

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

      // good
    }
  }

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

    RevCommit commit2 = git.commit().setMessage("commit2").call();
    assertNotNull(commit2);

    assertNotNull(git.checkout().setName(Constants.MASTER).call());

    DirCache cache = db.lockDirCache();
    cache.getEntry("test.txt").setFileMode(FileMode.EXECUTABLE_FILE);
    cache.write();
    assertTrue(cache.commit());
    cache.unlock();

    assertNotNull(git.commit().setMessage("commit3").call());

    db.getFS().setExecute(file, false);
    git.getRepository()
View Full Code Here

   * @throws IllegalStateException
   * @throws IOException
   */
  public String indexState(Repository repo, int includedOptions)
      throws IllegalStateException, IOException {
    DirCache dc = repo.readDirCache();
    StringBuilder sb = new StringBuilder();
    TreeSet<Long> timeStamps = null;

    // iterate once over the dircache just to collect all time stamps
    if (0 != (includedOptions & MOD_TIME)) {
      timeStamps = new TreeSet<Long>();
      for (int i=0; i<dc.getEntryCount(); ++i)
        timeStamps.add(Long.valueOf(dc.getEntry(i).getLastModified()));
    }

    // iterate again, now produce the result string
    for (int i=0; i<dc.getEntryCount(); ++i) {
      DirCacheEntry entry = dc.getEntry(i);
      sb.append("["+entry.getPathString()+", mode:" + entry.getFileMode());
      int stage = entry.getStage();
      if (stage != 0)
        sb.append(", stage:" + stage);
      if (0 != (includedOptions & MOD_TIME)) {
View Full Code Here

        clp.getRepository().getConfig().get(WorkingTreeOptions.KEY)));
      return 1;
    }

    if (new File(name).isFile()) {
      final DirCache dirc;
      try {
        dirc = DirCache.read(new File(name), FS.DETECTED);
      } catch (IOException e) {
        throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e);
      }
View Full Code Here

TOP

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

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.