You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TreeWalkJava7Test.java 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (C) 2012-2013, Robin Rosenberg <robin.rosenberg@dewire.com> 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.treewalk;
  11. import static org.junit.Assert.assertEquals;
  12. import static org.junit.Assert.assertFalse;
  13. import static org.junit.Assert.assertTrue;
  14. import java.io.File;
  15. import org.eclipse.jgit.junit.RepositoryTestCase;
  16. import org.eclipse.jgit.util.FS;
  17. import org.junit.Test;
  18. public class TreeWalkJava7Test extends RepositoryTestCase {
  19. @Test
  20. public void testSymlinkToDirNotRecursingViaSymlink() throws Exception {
  21. org.junit.Assume.assumeTrue(FS.DETECTED.supportsSymlinks());
  22. FS fs = db.getFS();
  23. assertTrue(fs.supportsSymlinks());
  24. writeTrashFile("target/data", "targetdata");
  25. fs.createSymLink(new File(trash, "link"), "target");
  26. try (TreeWalk tw = new TreeWalk(db)) {
  27. tw.setRecursive(true);
  28. tw.addTree(new FileTreeIterator(db));
  29. assertTrue(tw.next());
  30. assertEquals("link", tw.getPathString());
  31. assertTrue(tw.next());
  32. assertEquals("target/data", tw.getPathString());
  33. assertFalse(tw.next());
  34. }
  35. }
  36. }