aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2019-06-03 14:03:49 -0700
committerJonathan Nieder <jrn@google.com>2019-06-27 16:27:33 -0700
commit4973f05252b2159d9ceff4f480d252a596a669a1 (patch)
tree30eb4328601a56c3fed5eced07fa37f06c0be90e /org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
parentcbccfed4b39fd49cdb5366194b516a32ace58d62 (diff)
downloadjgit-4973f05252b2159d9ceff4f480d252a596a669a1.tar.gz
jgit-4973f05252b2159d9ceff4f480d252a596a669a1.zip
RevWalk: Add a setFirstParent that mimics C git's --first-parent
RevWalk does not currently provide a --first-parent equivalent and the feature has been requested. Add a field to the RevWalk class to specify whether walks should traverse first parents only. Modify Generator implementations to support the feature. Change-Id: I4a9a0d5767f82141dcf6d08659d7cb77c585fae4 Signed-off-by: Dave Borowitz <dborowitz@google.com> Signed-off-by: Alex Spradlin <alexaspradlin@google.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
index 247a3bdb28..7b5e6fa310 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/AbstractRevQueue.java
@@ -49,6 +49,10 @@ abstract class AbstractRevQueue extends Generator {
/** Current output flags set for this generator instance. */
int outputType;
+ AbstractRevQueue(boolean firstParent) {
+ super(firstParent);
+ }
+
/**
* Add a commit to the queue.
* <p>
@@ -96,10 +100,15 @@ abstract class AbstractRevQueue extends Generator {
*/
public final void addParents(RevCommit c, RevFlag queueControl) {
final RevCommit[] pList = c.parents;
- if (pList == null)
+ if (pList == null) {
return;
- for (RevCommit p : pList)
- add(p, queueControl);
+ }
+ for (int i = 0; i < pList.length; i++) {
+ if (firstParent && i > 0) {
+ break;
+ }
+ add(pList[i], queueControl);
+ }
}
/**
@@ -138,6 +147,10 @@ abstract class AbstractRevQueue extends Generator {
}
private static class AlwaysEmptyQueue extends AbstractRevQueue {
+ private AlwaysEmptyQueue() {
+ super(false);
+ }
+
@Override
public void add(RevCommit c) {
throw new UnsupportedOperationException();