summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java17
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java11
2 files changed, 24 insertions, 4 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java
index 200cb6a4fe..0a045c917b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkUtilsReachableTest.java
@@ -82,20 +82,33 @@ public class RevWalkUtilsReachableTest extends RevWalkTestCase {
* a b
* | |
* c d
+ * | \
+ * f e
+ * | /
+ * g
*/
RevCommit a = commit();
RevCommit b = commit();
RevCommit c = commit(a);
RevCommit d = commit(b);
+ RevCommit f = commit(d);
+ RevCommit e = commit(d);
+ RevCommit g = commit(f, e);
Ref branchA = branch("a", a);
Ref branchB = branch("b", b);
Ref branchC = branch("c", c);
Ref branchD = branch("d", d);
+ Ref branchE = branch("e", e);
+ Ref branchF = branch("f", f);
+ Ref branchG = branch("g", g);
assertContains(a, asList(branchA, branchC));
- assertContains(b, asList(branchB, branchD));
+ assertContains(b, asList(branchB, branchD, branchE, branchF, branchG));
assertContains(c, asList(branchC));
- assertContains(d, asList(branchD));
+ assertContains(d, asList(branchD, branchE, branchF, branchG));
+ assertContains(e, asList(branchE, branchG));
+ assertContains(f, asList(branchF, branchG));
+ assertContains(g, asList(branchG));
}
private Ref branch(String name, RevCommit dst) throws Exception {
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 d5b3643af9..d2ab4a19e8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
@@ -528,6 +528,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
Enum returnStrategy, ProgressMonitor monitor) throws IOException {
List<Ref> result = new ArrayList<>();
List<RevCommit> uninteresting = new ArrayList<>();
+ List<RevCommit> marked = new ArrayList<>();
RevFilter oldRF = filter;
TreeFilter oldTF = treeFilter;
try {
@@ -545,17 +546,20 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
continue;
}
RevCommit c = (RevCommit) o;
- resetRetain(RevFlag.UNINTERESTING);
+ reset(UNINTERESTING | TEMP_MARK);
markStart(c);
boolean commitFound = false;
RevCommit next;
while ((next = next()) != null) {
- if (References.isSameObject(next, needle)) {
+ if (References.isSameObject(next, needle)
+ || (next.flags & TEMP_MARK) != 0) {
result.add(r);
if (returnStrategy == GetMergedIntoStrategy.RETURN_ON_FIRST_FOUND) {
return result;
}
commitFound = true;
+ c.flags |= TEMP_MARK;
+ marked.add(c);
break;
}
}
@@ -571,6 +575,9 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
roots.addAll(uninteresting);
filter = oldRF;
treeFilter = oldTF;
+ for (RevCommit c : marked) {
+ c.flags &= ~TEMP_MARK;
+ }
}
return result;
}