Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

RevWalkCullTest.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2009, Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.revwalk;
  11. import static org.junit.Assert.assertNull;
  12. import org.junit.Test;
  13. public class RevWalkCullTest extends RevWalkTestCase {
  14. @Test
  15. public void testProperlyCullAllAncestors1() throws Exception {
  16. // Credit goes to Junio C Hamano <gitster@pobox.com> for this
  17. // test case in git-core (t/t6009-rev-list-parent.sh)
  18. //
  19. // We induce a clock skew so two is dated before one.
  20. //
  21. final RevCommit a = commit();
  22. final RevCommit b = commit(-2400, a);
  23. final RevCommit c = commit(b);
  24. final RevCommit d = commit(c);
  25. markStart(a);
  26. markUninteresting(d);
  27. assertNull(rw.next());
  28. }
  29. @Test
  30. public void testProperlyCullAllAncestors2() throws Exception {
  31. // Despite clock skew on c1 being very old it should not
  32. // produce, neither should a or b, or any part of that chain.
  33. //
  34. final RevCommit a = commit();
  35. final RevCommit b = commit(a);
  36. final RevCommit c1 = commit(-5, b);
  37. final RevCommit c2 = commit(10, b);
  38. final RevCommit d = commit(c1, c2);
  39. markStart(d);
  40. markUninteresting(c1);
  41. assertCommit(d, rw.next());
  42. assertCommit(c2, rw.next());
  43. assertNull(rw.next());
  44. }
  45. @Test
  46. public void testProperlyCullAllAncestors_LongHistory() throws Exception {
  47. RevCommit a = commit();
  48. RevCommit b = commit(a);
  49. for (int i = 0; i < 24; i++) {
  50. b = commit(b);
  51. if ((i & 2) == 0)
  52. markUninteresting(b);
  53. }
  54. final RevCommit c = commit(b);
  55. // TestRepository eagerly parses newly created objects. The current rw
  56. // is caching that parsed state. To verify that RevWalk itself is lazy,
  57. // set up a new one.
  58. rw.close();
  59. rw = createRevWalk();
  60. RevCommit a2 = rw.lookupCommit(a);
  61. markStart(c);
  62. markUninteresting(b);
  63. assertCommit(c, rw.next());
  64. assertNull(rw.next());
  65. // We should have aborted before we got back so far that "a"
  66. // would be parsed. Thus, its parents shouldn't be allocated.
  67. //
  68. assertNull(a2.parents);
  69. }
  70. }