aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2014-05-06 14:05:14 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2014-05-06 14:05:14 -0400
commit79448bcf9492f9b164bfa77e0a9210147b7b89f1 (patch)
tree4183a4214f672e1be5102b2721080b645c4cd622 /org.eclipse.jgit/src/org/eclipse
parent7424d58255340fa44d9191a7436fbe70d72a457c (diff)
parent99008648d176c04842f8ccb99177579d0cbe89a0 (diff)
downloadjgit-79448bcf9492f9b164bfa77e0a9210147b7b89f1.tar.gz
jgit-79448bcf9492f9b164bfa77e0a9210147b7b89f1.zip
Merge changes I9ba0e70f,I1f38e055,Idb55a303
* changes: Do not rewrite parents in RevWalkTextBuiltins RevWalk: Allow disabling parent rewriting RevWalkTextBuiltin: Add -n to limit number of commits returned
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java29
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java4
2 files changed, 30 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
index b3c4cced74..79cc42d170 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
@@ -190,6 +190,8 @@ public class RevWalk implements Iterable<RevCommit> {
private boolean retainBody;
+ private boolean rewriteParents = true;
+
boolean shallowCommitsInitialized;
/**
@@ -533,8 +535,9 @@ public class RevWalk implements Iterable<RevCommit> {
* will not be simplified.
* <p>
* If non-null and not {@link TreeFilter#ALL} then the tree filter will be
- * installed and commits will have their ancestry simplified to hide commits
- * that do not contain tree entries matched by the filter.
+ * installed. Commits will have their ancestry simplified to hide commits that
+ * do not contain tree entries matched by the filter, unless
+ * {@code setRewriteParents(false)} is called.
* <p>
* Usually callers should be inserting a filter graph including
* {@link TreeFilter#ANY_DIFF} along with one or more
@@ -551,6 +554,28 @@ public class RevWalk implements Iterable<RevCommit> {
}
/**
+ * Set whether to rewrite parent pointers when filtering by modified paths.
+ * <p>
+ * By default, when {@link #setTreeFilter(TreeFilter)} is called with non-
+ * null and non-{@link TreeFilter#ALL} filter, commits will have their
+ * ancestry simplified and parents rewritten to hide commits that do not match
+ * the filter.
+ * <p>
+ * This behavior can be bypassed by passing false to this method.
+ *
+ * @param rewrite
+ * whether to rewrite parents; defaults to true.
+ * @since 3.4
+ */
+ public void setRewriteParents(boolean rewrite) {
+ rewriteParents = rewrite;
+ }
+
+ boolean getRewriteParents() {
+ return rewriteParents;
+ }
+
+ /**
* Should the body of a commit or tag be retained after parsing its headers?
* <p>
* Usually the body is always retained, but some application code might not
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java
index 5b264fcf3d..9c4e53c979 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/StartGenerator.java
@@ -128,7 +128,9 @@ class StartGenerator extends Generator {
pending = new DateRevQueue(q);
if (tf != TreeFilter.ALL) {
rf = AndRevFilter.create(new RewriteTreeFilter(w, tf), rf);
- pendingOutputType |= HAS_REWRITE | NEEDS_REWRITE;
+ pendingOutputType |= HAS_REWRITE;
+ if (w.getRewriteParents())
+ pendingOutputType |= NEEDS_REWRITE;
}
walker.queue = q;