1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.revwalk;
12
13 import static org.junit.Assert.assertNull;
14
15 import org.junit.Test;
16
17 public class RevWalkCullTest extends RevWalkTestCase {
18 @Test
19 public void testProperlyCullAllAncestors1() throws Exception {
20
21
22
23
24
25 final RevCommit a = commit();
26 final RevCommit b = commit(-2400, a);
27 final RevCommit c = commit(b);
28 final RevCommit d = commit(c);
29
30 markStart(a);
31 markUninteresting(d);
32 assertNull(rw.next());
33 }
34
35 @Test
36 public void testProperlyCullAllAncestors2() throws Exception {
37
38
39
40 final RevCommit a = commit();
41 final RevCommit b = commit(a);
42 final RevCommit c1 = commit(-5, b);
43 final RevCommit c2 = commit(10, b);
44 final RevCommit d = commit(c1, c2);
45
46 markStart(d);
47 markUninteresting(c1);
48 assertCommit(d, rw.next());
49 assertCommit(c2, rw.next());
50 assertNull(rw.next());
51 }
52
53 @Test
54 public void testProperlyCullAllAncestors_LongHistory() throws Exception {
55 RevCommit a = commit();
56 RevCommit b = commit(a);
57 for (int i = 0; i < 24; i++) {
58 b = commit(b);
59 if ((i & 2) == 0)
60 markUninteresting(b);
61 }
62 final RevCommit c = commit(b);
63
64
65
66
67 rw.close();
68 rw = createRevWalk();
69 RevCommit a2 = rw.lookupCommit(a);
70 markStart(c);
71 markUninteresting(b);
72 assertCommit(c, rw.next());
73 assertNull(rw.next());
74
75
76
77
78 assertNull(a2.parents);
79 }
80 }