当前位置: 首页>>代码示例>>Java>>正文


Java DirCache.getEntry方法代码示例

本文整理汇总了Java中org.eclipse.jgit.dircache.DirCache.getEntry方法的典型用法代码示例。如果您正苦于以下问题:Java DirCache.getEntry方法的具体用法?Java DirCache.getEntry怎么用?Java DirCache.getEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.dircache.DirCache的用法示例。


在下文中一共展示了DirCache.getEntry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteIfUnversioned

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private void deleteIfUnversioned(DirCache cache, String path, WorkingTreeIterator f, Repository repository, TreeWalk treeWalk) throws IOException, NoWorkTreeException {
    if (cache.getEntry(path) == null &&  // not in index 
        !f.isEntryIgnored() &&             // not ignored
        !Utils.isFromNested(f.getEntryFileMode().getBits()))
    {            
        File file = new File(repository.getWorkTree().getAbsolutePath() + File.separator + path);                        
        if(file.isDirectory()) {
            String[] s = file.list();
            if(s != null && s.length > 0) { // XXX is there no better way to find out if empty?
                // not empty
                return; 
            }
        }
        file.delete();
        listener.notifyFile(file, treeWalk.getPathString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CleanCommand.java

示例2: assertDirCacheEntryModified

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private void assertDirCacheEntryModified (Collection<File> files) throws IOException {
    DirCache cache = repository.lockDirCache();
    for (File f : files) {
        String relativePath = Utils.getRelativePath(workDir, f);
        DirCacheEntry e = cache.getEntry(relativePath);
        assertNotNull(e);
        assertEquals(relativePath, e.getPathString());
        InputStream in = new FileInputStream(f);
        try {
            assertNotSame(e.getObjectId(), repository.newObjectInserter().idFor(Constants.OBJ_BLOB, f.length(), in));
        } finally {
            in.close();
        }
    }
    cache.unlock();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AddTest.java

示例3: assertDirCacheEntry

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
protected static void assertDirCacheEntry (Repository repository, File workDir, Collection<File> files) throws IOException {
    DirCache cache = repository.lockDirCache();
    for (File f : files) {
        String relativePath = Utils.getRelativePath(workDir, f);
        DirCacheEntry e = cache.getEntry(relativePath);
        assertNotNull(e);
        assertEquals(relativePath, e.getPathString());
        if (f.lastModified() != e.getLastModified()) {
            assertEquals((f.lastModified() / 1000) * 1000, (e.getLastModified() / 1000) * 1000);
        }
        try (InputStream in = new FileInputStream(f)) {
            assertEquals(e.getObjectId(), repository.newObjectInserter().idFor(Constants.OBJ_BLOB, f.length(), in));
        }
        if (e.getLength() == 0 && f.length() != 0) {
            assertTrue(e.isSmudged());
        } else {
            assertEquals(f.length(), e.getLength());
        }
    }
    cache.unlock();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AbstractGitTestCase.java

示例4: findEntrys

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private DirCacheEntry[] findEntrys(Repository repository, String path) throws IOException {
    DirCache dirCache = repository.readDirCache();

    int eIdx = dirCache.findEntry(path);
    if (eIdx < 0) {
        throw new GitInvalidPathException(format("%s is not found in git index", path));
    }

    int lastIdx = dirCache.nextEntry(eIdx);

    final DirCacheEntry[] entries = new DirCacheEntry[lastIdx - eIdx];
    for (int i=0; i<entries.length; i++) {
        entries[i] = dirCache.getEntry(eIdx + i);
    }

    return entries;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:18,代码来源:GitManagerImpl.java

示例5: main

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        // DirCache contains all files of the repository
        DirCache index = DirCache.read(repository);
        System.out.println("DirCache has " + index.getEntryCount() + " items");
        for (int i = 0; i < index.getEntryCount(); i++) {
            // the number after the AnyObjectId is the "stage", see the constants in DirCacheEntry
            System.out.println("Item " + i + ": " + index.getEntry(i));
        }

        //
        System.out.println("Now printing staged items...");
        for (int i = 0; i < index.getEntryCount(); i++) {
            DirCacheEntry entry = index.getEntry(i);
            if (entry.getStage() != DirCacheEntry.STAGE_0) {
                System.out.println("Item " + i + ": " + entry);
            }
        }
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:21,代码来源:ListIndex.java

示例6: call

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
@Override
public String call() throws GitAPIException {
	try {
		DirCache index = repo.lockDirCache();
		DirCacheEntry entry = index.getEntry(fileName);

		if (entry != null) {
			entry.setAssumeValid(assumeUnchanged);
			index.write();
			index.commit();
			return entry.getPathString();
		}
	} catch (IOException e) {
		throw new JGitInternalException(e.getMessage(), e);
	}

	return null;
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:19,代码来源:UpdateIndex.java

示例7: assertNullDirCacheEntry

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private void assertNullDirCacheEntry (Collection<File> files) throws Exception {
    DirCache cache = repository.lockDirCache();
    for (File f : files) {
        DirCacheEntry e = cache.getEntry(Utils.getRelativePath(workDir, f));
        assertNull(e);
    }
    cache.unlock();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CleanTest.java

示例8: testLargeFile

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public void testLargeFile () throws Exception {
    unpack("large.dat.zip");
    File large = new File(workDir, "large.dat");
    assertTrue(large.exists());
    assertEquals(2158310, large.length());
    add();
    DirCache cache = repository.readDirCache();
    DirCacheEntry e = cache.getEntry("large.dat");
    WindowCacheConfig cfg = new WindowCacheConfig();
    cfg.setStreamFileThreshold((int) large.length() - 1);
    cfg.install();
    DirCacheCheckout.checkoutEntry(repository, large, e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CheckoutTest.java

示例9: testResetConflict

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
public void testResetConflict () throws Exception {
    File file = new File(workDir, "file");
    write(file, "init");
    File[] files = new File[] { file };
    add(files);
    commit(files);

    DirCache index = repository.lockDirCache();
    DirCacheBuilder builder = index.builder();
    DirCacheEntry e = index.getEntry(file.getName());
    DirCacheEntry e1 = new DirCacheEntry(file.getName(), 1);
    e1.setCreationTime(e.getCreationTime());
    e1.setFileMode(e.getFileMode());
    e1.setLastModified(e.getLastModified());
    e1.setLength(e.getLength());
    e1.setObjectId(e.getObjectId());
    builder.add(e1);
    builder.finish();
    builder.commit();
    
    GitClient client = getClient(workDir);
    Map<File, GitStatus> status = client.getStatus(files, NULL_PROGRESS_MONITOR);
    assertTrue(status.get(file).isConflict());
    assertEquals(GitConflictDescriptor.Type.BOTH_DELETED, status.get(file).getConflictDescriptor().getType());
    
    client.reset(files, "HEAD", true, NULL_PROGRESS_MONITOR);
    status = client.getStatus(files, NULL_PROGRESS_MONITOR);
    assertFalse(status.get(file).isConflict());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ResetTest.java

示例10: locateObjectIdInIndex

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
/**
 * Locates the file with the given path in the index.
 * 
 * @param path File path.
 * 
 * @return The ID or null if not found.
 * 
 * @throws IOException Unable to read the index.
 */
public ObjectId locateObjectIdInIndex(String path)  throws IOException {
  DirCache dc = git.getRepository().readDirCache();
  int firstIndex = dc.findEntry(path);
  if (firstIndex < 0) {
    return null;
  }

  org.eclipse.jgit.dircache.DirCacheEntry firstEntry = dc.getEntry(firstIndex);
  
  return firstEntry.getObjectId();
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:21,代码来源:GitAccess.java

示例11: updateSubmodule

import org.eclipse.jgit.dircache.DirCache; //导入方法依赖的package包/类
private RevCommit updateSubmodule(
    DirCache dc, DirCacheEditor ed, StringBuilder msgbuf, SubmoduleSubscription s)
    throws SubmoduleException, IOException {
  OpenRepo subOr;
  try {
    subOr = orm.getRepo(s.getSubmodule().getParentKey());
  } catch (NoSuchProjectException | IOException e) {
    throw new SubmoduleException("Cannot access submodule", e);
  }

  DirCacheEntry dce = dc.getEntry(s.getPath());
  RevCommit oldCommit = null;
  if (dce != null) {
    if (!dce.getFileMode().equals(FileMode.GITLINK)) {
      String errMsg =
          "Requested to update gitlink "
              + s.getPath()
              + " in "
              + s.getSubmodule().getParentKey().get()
              + " but entry "
              + "doesn't have gitlink file mode.";
      throw new SubmoduleException(errMsg);
    }
    oldCommit = subOr.rw.parseCommit(dce.getObjectId());
  }

  final CodeReviewCommit newCommit;
  if (branchTips.containsKey(s.getSubmodule())) {
    newCommit = branchTips.get(s.getSubmodule());
  } else {
    Ref ref = subOr.repo.getRefDatabase().exactRef(s.getSubmodule().get());
    if (ref == null) {
      ed.add(new DeletePath(s.getPath()));
      return null;
    }
    newCommit = subOr.rw.parseCommit(ref.getObjectId());
    addBranchTip(s.getSubmodule(), newCommit);
  }

  if (Objects.equals(newCommit, oldCommit)) {
    // gitlink have already been updated for this submodule
    return null;
  }
  ed.add(
      new PathEdit(s.getPath()) {
        @Override
        public void apply(DirCacheEntry ent) {
          ent.setFileMode(FileMode.GITLINK);
          ent.setObjectId(newCommit.getId());
        }
      });

  if (verboseSuperProject != VerboseSuperprojectUpdate.FALSE) {
    createSubmoduleCommitMsg(msgbuf, s, subOr, newCommit, oldCommit);
  }
  subOr.rw.parseBody(newCommit);
  return newCommit;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:59,代码来源:SubmoduleOp.java


注:本文中的org.eclipse.jgit.dircache.DirCache.getEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。