diff options
author | Stefan Lay <stefan.lay@sap.com> | 2011-04-06 14:58:48 +0200 |
---|---|---|
committer | Stefan Lay <stefan.lay@sap.com> | 2011-04-06 14:58:48 +0200 |
commit | 792b93bc62bb3714eb04ccf6e0c800d3b5b85f5b (patch) | |
tree | 255e588995626e8c0bad4d407fe6e2e9dd817a6b /org.eclipse.jgit.test | |
parent | e24005de2d28bf6c246e2ce4e5413ae136920877 (diff) | |
download | jgit-792b93bc62bb3714eb04ccf6e0c800d3b5b85f5b.tar.gz jgit-792b93bc62bb3714eb04ccf6e0c800d3b5b85f5b.zip |
Try to checkout branch after cloning
When no branch was specified in the clone command, HEAD pointed to a
commit after clone. Now the clone command tries to find a branch which
points to the same commit and checks out this branch.
Bug: 339354
Change-Id: Ie3844465329f213dee4a8868dbf434ac3ce23a08
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java | 19 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java | 4 |
2 files changed, 19 insertions, 4 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 51ae054da3..f2ad9e5f11 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 @@ -50,6 +50,7 @@ import java.io.File; import java.io.IOException; import org.eclipse.jgit.junit.TestRepository; +import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.RefUpdate; @@ -99,6 +100,20 @@ public class CloneCommandTest extends RepositoryTestCase { assertNotNull(git2); ObjectId id = git2.getRepository().resolve("tag-for-blob"); assertNotNull(id); + assertEquals(git2.getRepository().getFullBranch(), + "refs/heads/test"); + assertEquals( + "origin", + git2.getRepository() + .getConfig() + .getString(ConfigConstants.CONFIG_BRANCH_SECTION, + "test", ConfigConstants.CONFIG_KEY_REMOTE)); + assertEquals( + "refs/heads/test", + git2.getRepository() + .getConfig() + .getString(ConfigConstants.CONFIG_BRANCH_SECTION, + "test", ConfigConstants.CONFIG_KEY_MERGE)); } catch (Exception e) { fail(e.getMessage()); } @@ -109,14 +124,14 @@ public class CloneCommandTest extends RepositoryTestCase { try { File directory = createTempDirectory("testCloneRepositoryWithBranch"); CloneCommand command = Git.cloneRepository(); - command.setBranch("refs/heads/test"); + command.setBranch("refs/heads/master"); command.setDirectory(directory); command.setURI("file://" + git.getRepository().getWorkTree().getPath()); Git git2 = command.call(); assertNotNull(git2); assertEquals(git2.getRepository().getFullBranch(), - "refs/heads/test"); + "refs/heads/master"); } catch (Exception e) { fail(e.getMessage()); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java index cfaac6352f..4075586b51 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java @@ -78,7 +78,7 @@ public class GitConstructionTest extends RepositoryTestCase { assertEquals(1, git.branchList().call().size()); git = Git.wrap(bareRepo); - assertEquals(1, git.branchList().setListMode(ListMode.ALL).call() + assertEquals(2, git.branchList().setListMode(ListMode.ALL).call() .size()); try { @@ -95,7 +95,7 @@ public class GitConstructionTest extends RepositoryTestCase { assertEquals(1, git.branchList().call().size()); git = Git.open(bareRepo.getDirectory()); - assertEquals(1, git.branchList().setListMode(ListMode.ALL).call() + assertEquals(2, git.branchList().setListMode(ListMode.ALL).call() .size()); git = Git.open(db.getWorkTree()); |