diff options
author | Andrey Loskutov <loskutov@gmx.de> | 2015-08-16 13:00:00 +0200 |
---|---|---|
committer | Andrey Loskutov <loskutov@gmx.de> | 2015-10-09 09:23:30 -0400 |
commit | a406ebf4018f2912f90aa2473c522556a742d015 (patch) | |
tree | b0ab06cc22e204fc4431d82a1eca9e71c7c474f7 /org.eclipse.jgit.junit | |
parent | 227b78f087fa583b17130613a37b7fd904e92ffc (diff) | |
download | jgit-a406ebf4018f2912f90aa2473c522556a742d015.tar.gz jgit-a406ebf4018f2912f90aa2473c522556a742d015.zip |
Delete non empty directories before checkout a path
If the checkout path is currently a non-empty directory (and was a link
or a regular file before), this directory will be removed before
performing checkout, but only if the checkout path is specified.
Bug: 474973
Change-Id: Ifc6c61592d9b54d26c66367163acdebea369145c
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java | 7 | ||||
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java index 136c64726f..521593ea80 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java @@ -55,6 +55,7 @@ import java.io.Writer; import java.lang.reflect.Method; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Path; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.util.FileUtils; @@ -240,4 +241,10 @@ public abstract class JGitTestUtil { FileUtils.delete(path); } + public static Path writeLink(Repository db, String link, + String target) throws Exception { + return FileUtils.createSymLink(new File(db.getWorkTree(), link), + target); + } + } diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java index ac4539a848..28c61778c7 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java @@ -55,6 +55,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.file.Path; import java.util.Map; import org.eclipse.jgit.api.Git; @@ -107,6 +108,11 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { return JGitTestUtil.writeTrashFile(db, name, data); } + protected Path writeLink(final String link, final String target) + throws Exception { + return JGitTestUtil.writeLink(db, link, target); + } + protected File writeTrashFile(final String subdir, final String name, final String data) throws IOException { |