diff options
author | Shawn Pearce <spearce@spearce.org> | 2011-03-27 16:55:54 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2011-03-27 16:55:54 -0400 |
commit | 23967441fc5b72996f5f29e197d52e763a14cb32 (patch) | |
tree | bb779309f694a1686831ad729613b0052fb56a51 /org.eclipse.jgit.test/tst/org/eclipse/jgit | |
parent | 6e10c1da0018d2be47e4a0ac06a18205e82da673 (diff) | |
parent | 3a86868c0883d2a564db88bf9ae4a5fe235bb63f (diff) | |
download | jgit-23967441fc5b72996f5f29e197d52e763a14cb32.tar.gz jgit-23967441fc5b72996f5f29e197d52e763a14cb32.zip |
Merge "Detaching HEAD when checking out the same commit."
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java | 17 |
1 files changed, 17 insertions, 0 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 21fbe0a134..6e9f851793 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 @@ -47,6 +47,7 @@ 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.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -239,4 +240,20 @@ public class CheckoutCommandTest extends RepositoryTestCase { fail(e.getMessage()); } } + + @Test + public void testDetachedHeadOnCheckout() throws JGitInternalException, + RefAlreadyExistsException, RefNotFoundException, + InvalidRefNameException, IOException { + CheckoutCommand co = git.checkout(); + co.setName("master").call(); + + String commitId = db.getRef(Constants.MASTER).getObjectId().name(); + co = git.checkout(); + co.setName(commitId).call(); + + Ref head = db.getRef(Constants.HEAD); + assertFalse(head.isSymbolic()); + assertSame(head, head.getTarget()); + } } |