summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2019-10-26 01:00:16 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-11-15 16:00:48 -0800
commit1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd (patch)
tree4aee7f85a70298f94d206d0cbab600eaccdc3365 /org.eclipse.jgit.test
parent345e2648df3e17bd18d0f4251774d3f8b298f77c (diff)
downloadjgit-1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd.tar.gz
jgit-1daf6f13aa4a77c32ddc86b829d4e4ec32bb35dd.zip
RewriteGenerator: avoid adding null parent
Prevent adding a null parent to a commit's parent array. Doing so can cause NPEs later on. Bug: 552160 Change-Id: Ib24b7b9b7b08e0b6f246006b4a4cade7eeb830b9 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FirstParentRevWalkTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FirstParentRevWalkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FirstParentRevWalkTest.java
index 1fc7a55457..d46f48bcd9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FirstParentRevWalkTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/FirstParentRevWalkTest.java
@@ -49,6 +49,7 @@ import static org.junit.Assert.assertNull;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.filter.MessageRevFilter;
import org.eclipse.jgit.revwalk.filter.RevFilter;
+import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.junit.Test;
public class FirstParentRevWalkTest extends RevWalkTestCase {
@@ -425,4 +426,39 @@ public class FirstParentRevWalkTest extends RevWalkTestCase {
markStart(a);
assertNull(rw.next());
}
+
+ @Test
+ public void testWithTopoSortAndTreeFilter() throws Exception {
+ RevCommit a = commit();
+ RevCommit b = commit(tree(file("0", blob("b"))), a);
+ RevCommit c = commit(tree(file("0", blob("c"))), b, a);
+ RevCommit d = commit(tree(file("0", blob("d"))), c);
+
+ rw.reset();
+ rw.setFirstParent(true);
+ rw.sort(RevSort.TOPO, true);
+ rw.setTreeFilter(PathFilterGroup.createFromStrings("0"));
+ markStart(d);
+ assertCommit(d, rw.next());
+ assertCommit(c, rw.next());
+ assertCommit(b, rw.next());
+ assertNull(rw.next());
+ }
+
+ @Test
+ public void testWithTopoSortAndTreeFilter2() throws Exception {
+ RevCommit a = commit();
+ RevCommit b = commit(tree(file("0", blob("b"))), a);
+ RevCommit c = commit(tree(file("0", blob("c"))), a, b);
+ RevCommit d = commit(tree(file("0", blob("d"))), c);
+
+ rw.reset();
+ rw.setFirstParent(true);
+ rw.sort(RevSort.TOPO, true);
+ rw.setTreeFilter(PathFilterGroup.createFromStrings("0"));
+ markStart(d);
+ assertCommit(d, rw.next());
+ assertCommit(c, rw.next());
+ assertNull(rw.next());
+ }
}