summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
index de430fc94f..06829fa4db 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
@@ -45,6 +45,7 @@ package org.eclipse.jgit.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -58,6 +59,7 @@ import java.util.Map;
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.ConfigConstants;
@@ -136,6 +138,54 @@ public class CloneCommandTest extends RepositoryTestCase {
}
@Test
+ public void testCloneRepositoryExplicitGitDir() throws IOException,
+ JGitInternalException, GitAPIException {
+ File directory = createTempDirectory("testCloneRepository");
+ CloneCommand command = Git.cloneRepository();
+ command.setDirectory(directory);
+ command.setGitDir(new File(directory, ".git"));
+ command.setURI(fileUri());
+ Git git2 = command.call();
+ assertEquals(directory, git2.getRepository().getWorkTree());
+ assertEquals(new File(directory, ".git"), git2.getRepository()
+ .getDirectory());
+ }
+
+ @Test
+ public void testCloneRepositoryExplicitGitDirNonStd() throws IOException,
+ JGitInternalException, GitAPIException {
+ File directory = createTempDirectory("testCloneRepository");
+ File gDir = createTempDirectory("testCloneRepository.git");
+ CloneCommand command = Git.cloneRepository();
+ command.setDirectory(directory);
+ command.setGitDir(gDir);
+ command.setURI(fileUri());
+ Git git2 = command.call();
+ assertEquals(directory, git2.getRepository().getWorkTree());
+ assertEquals(gDir, git2.getRepository()
+ .getDirectory());
+ assertTrue(new File(directory, ".git").isFile());
+ assertFalse(new File(gDir, ".git").exists());
+ }
+
+ @Test
+ public void testCloneRepositoryExplicitGitDirBare() throws IOException,
+ JGitInternalException, GitAPIException {
+ File gDir = createTempDirectory("testCloneRepository.git");
+ CloneCommand command = Git.cloneRepository();
+ command.setBare(true);
+ command.setGitDir(gDir);
+ command.setURI(fileUri());
+ Git git2 = command.call();
+ try {
+ assertNull(null, git2.getRepository().getWorkTree());
+ fail("Expected NoWorkTreeException");
+ } catch (NoWorkTreeException e) {
+ assertEquals(gDir, git2.getRepository().getDirectory());
+ }
+ }
+
+ @Test
public void testBareCloneRepository() throws IOException,
JGitInternalException, GitAPIException, URISyntaxException {
File directory = createTempDirectory("testCloneRepository_bare");