Example usage for org.eclipse.jgit.dircache DirCacheEntry getLastModified

List of usage examples for org.eclipse.jgit.dircache DirCacheEntry getLastModified

Introduction

In this page you can find the example usage for org.eclipse.jgit.dircache DirCacheEntry getLastModified.

Prototype

@Deprecated
public long getLastModified() 

Source Link

Document

Get the cached last modification date of this file, in milliseconds.

Usage

From source file:com.itemis.maven.plugins.unleash.scm.providers.merge.UnleashGitMerger.java

License:Eclipse Distribution License

/**
 * adds a entry to the index builder which is a copy of the specified
 * DirCacheEntry//  w  ww . j ava 2s  .c  o m
 *
 * @param e
 *          the entry which should be copied
 *
 * @return the entry which was added to the index
 */
private DirCacheEntry keep(DirCacheEntry e) {
    DirCacheEntry newEntry = new DirCacheEntry(e.getPathString(), e.getStage());
    newEntry.setFileMode(e.getFileMode());
    newEntry.setObjectId(e.getObjectId());
    newEntry.setLastModified(e.getLastModified());
    newEntry.setLength(e.getLength());
    this.builder.add(newEntry);
    return newEntry;
}

From source file:org.eclipse.orion.server.git.jobs.StashApplyCommand.java

License:Eclipse Distribution License

private void resetIndex(RevTree tree) throws IOException {
    DirCache dc = repo.lockDirCache();//from   w w  w .jav a  2 s .  com
    TreeWalk walk = null;
    try {
        DirCacheBuilder builder = dc.builder();

        walk = new TreeWalk(repo);
        walk.addTree(tree);
        walk.addTree(new DirCacheIterator(dc));
        walk.setRecursive(true);

        while (walk.next()) {
            AbstractTreeIterator cIter = walk.getTree(0, AbstractTreeIterator.class);
            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);
        }

        builder.commit();
    } finally {
        dc.unlock();
        if (walk != null)
            walk.release();
    }
}