summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2013-03-15 08:10:59 -0700
committerDave Borowitz <dborowitz@google.com>2013-03-15 08:58:14 -0700
commitbba74ba2e0af10db4d75258819ca0a1b4307e377 (patch)
treec7a8602fa8c063a8d18a3c648de4e35a165fadb7 /org.eclipse.jgit.test
parent0adcbba1495b2f677461c526a8a191c236064f7c (diff)
downloadjgit-bba74ba2e0af10db4d75258819ca0a1b4307e377.tar.gz
jgit-bba74ba2e0af10db4d75258819ca0a1b4307e377.zip
NameRevCommand: Don't use merge cost for first parent
Treat first parent traversals as 1 and higher parents as MERGE_COST, to match git name-rev. Allow overriding the merge cost during tests to avoid creating 2^16 commits on the fly. Change-Id: I0175e0c3ab1abe6722e4241abe2f106d1fe92a69
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java31
1 files changed, 14 insertions, 17 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java
index 26dc2d05a6..b92a636f58 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NameRevCommandTest.java
@@ -162,7 +162,7 @@ public class NameRevCommandTest extends RepositoryTestCase {
}
@Test
- public void oneMergeDifferentLengths() throws Exception {
+ public void onePathMergeLongerFirstParentPath() throws Exception {
// 0--1--2--4
// \--3---/
RevCommit c0 = tr.commit().create();
@@ -171,27 +171,24 @@ public class NameRevCommandTest extends RepositoryTestCase {
RevCommit c3 = tr.commit().parent(c0).create();
RevCommit c4 = tr.commit().parent(c2).parent(c3).create();
tr.update("master", c4);
- assertOneResult("master^2~1", c0);
+ assertOneResult("master^2", c3);
+ assertOneResult("master~3", c0);
}
@Test
- public void longerPathWithoutMerge() throws Exception {
- // 0--1--2--4 <- master
- // \ \-3-/
- // \--5--6--7--8--9 <- branch
+ public void multiplePathsSecondParent() throws Exception {
+ // 0--...--2
+ // \--1--/
RevCommit c0 = tr.commit().create();
RevCommit c1 = tr.commit().parent(c0).create();
- RevCommit c2 = tr.commit().parent(c1).create();
- RevCommit c3 = tr.commit().parent(c1).create();
- RevCommit c4 = tr.commit().parent(c2).parent(c3).create();
- RevCommit c5 = tr.commit().parent(c0).create();
- RevCommit c6 = tr.commit().parent(c5).create();
- RevCommit c7 = tr.commit().parent(c6).create();
- RevCommit c8 = tr.commit().parent(c7).create();
- RevCommit c9 = tr.commit().parent(c8).create();
- tr.update("master", c4);
- tr.update("branch", c9);
- assertOneResult("branch~5", c0);
+ RevCommit c = c0;
+ int mergeCost = 5;
+ for (int i = 0; i < mergeCost; i++) {
+ c = tr.commit().parent(c).create();
+ }
+ RevCommit c2 = tr.commit().parent(c).parent(c1).create();
+ tr.update("master", c2);
+ assertOneResult("master^2~1", git.nameRev().setMergeCost(mergeCost), c0);
}
private static void assertOneResult(String expected, NameRevCommand nameRev,