diff options
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java index 8487f880f1..f13fb20261 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java @@ -207,6 +207,28 @@ public class CheckoutCommandTest extends RepositoryTestCase { } @Test + public void testCheckoutLightweightTag() throws Exception { + git.tag().setAnnotated(false).setName("test-tag") + .setObjectId(initialCommit).call(); + Ref result = git.checkout().setName("test-tag").call(); + + assertNull(result); + assertEquals(initialCommit.getId(), db.resolve(Constants.HEAD)); + assertHeadDetached(); + } + + @Test + public void testCheckoutAnnotatedTag() throws Exception { + git.tag().setAnnotated(true).setName("test-tag") + .setObjectId(initialCommit).call(); + Ref result = git.checkout().setName("test-tag").call(); + + assertNull(result); + assertEquals(initialCommit.getId(), db.resolve(Constants.HEAD)); + assertHeadDetached(); + } + + @Test public void testCheckoutRemoteTrackingWithUpstream() throws Exception { Repository db2 = createRepositoryWithRemote(); @@ -326,9 +348,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { co = git.checkout(); co.setName(commitId).call(); - Ref head = db.getRef(Constants.HEAD); - assertFalse(head.isSymbolic()); - assertSame(head, head.getTarget()); + assertHeadDetached(); } @Test @@ -421,6 +441,12 @@ public class CheckoutCommandTest extends RepositoryTestCase { assertNull(db.resolve("HEAD")); } + private void assertHeadDetached() throws IOException { + Ref head = db.getRef(Constants.HEAD); + assertFalse(head.isSymbolic()); + assertSame(head, head.getTarget()); + } + private void assertRepositoryCondition(int files) throws GitAPIException { org.eclipse.jgit.api.Status status = this.git.status().call(); assertFalse(status.isClean()); |