Example usage for org.eclipse.jgit.dircache DirCache getEntriesWithin

List of usage examples for org.eclipse.jgit.dircache DirCache getEntriesWithin

Introduction

In this page you can find the example usage for org.eclipse.jgit.dircache DirCache getEntriesWithin.

Prototype

public DirCacheEntry[] getEntriesWithin(String path) 

Source Link

Document

Recursively get all entries within a subtree.

Usage

From source file:org.eclipse.egit.core.GitMoveDeleteHook.java

License:Open Source License

private boolean moveIndexContent(String dPath, final RepositoryMapping srcm, final String sPath)
        throws IOException {
    final DirCache sCache = srcm.getRepository().lockDirCache();
    final DirCacheEntry[] sEnt = sCache.getEntriesWithin(sPath);
    if (sEnt.length == 0) {
        sCache.unlock();//from  w ww. ja  v  a2s  .  c o  m
        return false;
    }

    final DirCacheEditor sEdit = sCache.editor();
    sEdit.add(new DirCacheEditor.DeleteTree(sPath));
    final int sPathLen = sPath.length() + 1;
    for (final DirCacheEntry se : sEnt) {
        final String p = se.getPathString().substring(sPathLen);
        sEdit.add(new DirCacheEditor.PathEdit(dPath + p) {
            @Override
            public void apply(final DirCacheEntry dEnt) {
                dEnt.copyMetaData(se);
            }
        });
    }
    return sEdit.commit();
}

From source file:org.eclipse.egit.core.op.AssumeUnchangedOperation.java

License:Open Source License

private void assumeValid(final IResource resource) throws CoreException {
    final IProject proj = resource.getProject();
    final GitProjectData pd = GitProjectData.get(proj);
    if (pd == null)
        return;/*www .ja v a 2  s.  c  o m*/
    final RepositoryMapping rm = pd.getRepositoryMapping(resource);
    if (rm == null)
        return;
    final Repository db = rm.getRepository();

    DirCache cache = caches.get(db);
    if (cache == null) {
        try {
            cache = db.lockDirCache();
        } catch (IOException err) {
            throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, err));
        }
        caches.put(db, cache);
        mappings.put(rm, rm);
    }

    final String path = rm.getRepoRelativePath(resource);
    if (resource instanceof IContainer) {
        for (final DirCacheEntry ent : cache.getEntriesWithin(path))
            ent.setAssumeValid(assumeUnchanged);
    } else {
        final DirCacheEntry ent = cache.getEntry(path);
        if (ent != null)
            ent.setAssumeValid(assumeUnchanged);
    }
}

From source file:org.eclipse.emf.compare.git.pgm.AbstractApplicationTest.java

License:Open Source License

protected RevCommit addAllAndCommit(String commitMessage)
        throws GitAPIException, NoFilepatternException, NoHeadException, NoMessageException,
        UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException {
    DirCache dirChache = git.add().addFilepattern(".").call(); //$NON-NLS-1$
    // Assert there is something to commit
    assertTrue(dirChache.getEntriesWithin("").length > 0);
    RevCommit revCommit = git.commit().setAuthor("Logical test author", "logicaltest@obeo.fr")
            .setCommitter("Logical test author", "logicaltest@obeo.fr").setMessage(commitMessage).call();
    return revCommit;
}