Example usage for org.eclipse.jgit.revwalk.filter RevFilter NO_MERGES

List of usage examples for org.eclipse.jgit.revwalk.filter RevFilter NO_MERGES

Introduction

In this page you can find the example usage for org.eclipse.jgit.revwalk.filter RevFilter NO_MERGES.

Prototype

RevFilter NO_MERGES

To view the source code for org.eclipse.jgit.revwalk.filter RevFilter NO_MERGES.

Click Source Link

Document

Excludes commits with more than one parent (thread safe).

Usage

From source file:org.nbgit.util.GitCommand.java

License:Open Source License

public static RepositoryRevision.Walk getLogMessages(String rootPath, Set<File> files, String fromRevision,
        String toRevision, boolean showMerges, OutputLogger logger) {
    File root = new File(rootPath);
    Repository repo = Git.getInstance().getRepository(root);
    RepositoryRevision.Walk walk = new RepositoryRevision.Walk(repo);

    try {//  ww  w.  j  a  v a  2 s  . c  om
        if (fromRevision == null) {
            fromRevision = Constants.HEAD;
        }
        ObjectId from = repo.resolve(fromRevision);
        if (from == null) {
            return null;
        }
        walk.markStart(walk.parseCommit(from));
        ObjectId to = toRevision != null ? repo.resolve(toRevision) : null;
        if (to != null) {
            walk.markUninteresting(walk.parseCommit(to));
        }
        List<PathFilter> paths = new ArrayList<PathFilter>();
        for (File file : files) {
            String path = getRelative(root, file);

            if (!(path.length() == 0)) {
                paths.add(PathFilter.create(path));
            }
        }

        if (!paths.isEmpty()) {
            walk.setTreeFilter(PathFilterGroup.create(paths));
        }
        if (!showMerges) {
            walk.setRevFilter(RevFilter.NO_MERGES);
        }
    } catch (IOException ioe) {
        return null;
    }

    return walk;
}