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

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

Introduction

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

Prototype

@SuppressWarnings("boxing")
public DirCacheEntry(byte[] path, int stage) 

Source Link

Document

Create an empty entry at the specified stage.

Usage

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

License:Eclipse Distribution License

/**
 * adds a new path with the specified stage to the index builder
 *
 * @param path/*from  w  w  w. j  a va 2  s .c om*/
 * @param p
 * @param stage
 * @param lastMod
 * @param len
 * @return the entry which was added to the index
 */
private DirCacheEntry add(byte[] path, CanonicalTreeParser p, int stage, long lastMod, long len) {
    if (p != null && !p.getEntryFileMode().equals(FileMode.TREE)) {
        DirCacheEntry e = new DirCacheEntry(path, stage);
        e.setFileMode(p.getEntryFileMode());
        e.setObjectId(p.getEntryObjectId());
        e.setLastModified(lastMod);
        e.setLength(len);
        this.builder.add(e);
        return e;
    }
    return null;
}

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 w  w  . j a  v  a2s  . 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.egit.core.GitMoveDeleteHookTest.java

License:Open Source License

private static void addUnmergedEntry(String filePath, DirCacheBuilder builder) {
    DirCacheEntry stage1 = new DirCacheEntry(filePath, DirCacheEntry.STAGE_1);
    DirCacheEntry stage2 = new DirCacheEntry(filePath, DirCacheEntry.STAGE_2);
    DirCacheEntry stage3 = new DirCacheEntry(filePath, DirCacheEntry.STAGE_3);
    stage1.setFileMode(FileMode.REGULAR_FILE);
    stage2.setFileMode(FileMode.REGULAR_FILE);
    stage3.setFileMode(FileMode.REGULAR_FILE);
    builder.add(stage1);/*from w w  w. j a v  a 2s .co m*/
    builder.add(stage2);
    builder.add(stage3);
}

From source file:org.eclipse.egit.core.internal.storage.IndexFileRevisionTest.java

License:Open Source License

private DirCacheEntry entry(String path, int stage, String data) throws IOException {
    DirCacheEntry entry = new DirCacheEntry(path, stage);
    entry.setFileMode(FileMode.REGULAR_FILE);
    ObjectInserter inserter = repository.newObjectInserter();
    try {//ww  w . j  av  a2 s . c o m
        ObjectId blob = inserter.insert(Constants.OBJ_BLOB, data.getBytes("UTF-8"));
        entry.setObjectId(blob);
        inserter.flush();
    } finally {
        inserter.release();
    }
    return entry;
}

From source file:org.eclipse.emf.compare.egit.internal.merge.RecursiveModelMerger.java

License:Open Source License

private void add(String path, DirCacheBuilder cacheBuilder, TreeParserResourceVariant variant, int stage) {
    if (variant != null && !FileMode.TREE.equals(variant.getRawMode())) {
        DirCacheEntry e = new DirCacheEntry(path, stage);
        e.setFileMode(FileMode.fromBits(variant.getRawMode()));
        e.setObjectId(variant.getObjectId());
        e.setLastModified(0);//from  www .ja  v  a  2 s . co m
        e.setLength(0);
        cacheBuilder.add(e);
    }
}