Example usage for org.eclipse.jgit.lib IndexDiff getIndexMode

List of usage examples for org.eclipse.jgit.lib IndexDiff getIndexMode

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib IndexDiff getIndexMode.

Prototype

public FileMode getIndexMode(String path) 

Source Link

Document

Get the file mode of the given path in the index

Usage

From source file:org.jboss.tools.openshift.express.internal.ui.server.CommitDialog.java

License:Open Source License

/**
 * Set the total set of changed files, including additions and
 * removals//www  . j  a  v a 2 s . c  o  m
 * @param repository
 * @param paths paths of files potentially affected by a new commit
 * @param indexDiff IndexDiff of the related repository
 * @throws URISyntaxException 
 * @throws InvocationTargetException 
 * @throws IOException 
 */
public void setFiles(Repository repository, Set<String> paths, IndexDiff indexDiff) {
    this.repository = repository;
    items.clear();
    for (String path : paths) {
        CommitItem item = new CommitItem();
        item.status = getFileStatus(path, indexDiff);
        item.submodule = FileMode.GITLINK == indexDiff.getIndexMode(path);
        item.path = path;
        item.problemSeverity = getProblemSeverity(repository, path);
        items.add(item);
    }

    // initially, we sort by status plus path
    Collections.sort(items, new Comparator<CommitItem>() {
        @Override
        public int compare(CommitItem o1, CommitItem o2) {
            int diff = o1.status.ordinal() - o2.status.ordinal();
            if (diff != 0)
                return diff;
            return o1.path.compareTo(o2.path);
        }
    });
    this.isAhead = isAhead(remote, repository);
}