summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorSasa Zivkov <sasa.zivkov@sap.com>2011-07-05 14:06:49 +0200
committerChris Aniszczyk <caniszczyk@gmail.com>2011-07-12 10:48:59 -0500
commit1d4a1fe772745e80312543c0e4bf36974df49d4e (patch)
tree79abc37fa7bdfa830d26b39fdc779f9e52dee723 /org.eclipse.jgit.test
parentf0060f64a77b00e5cb164039eeae854c7aff38d0 (diff)
downloadjgit-1d4a1fe772745e80312543c0e4bf36974df49d4e.tar.gz
jgit-1d4a1fe772745e80312543c0e4bf36974df49d4e.zip
Fixed creation of branch from a tag
Creation of a branch X from an annotated tag, as the starting point, resulted into .git/refs/heads/X containing the ID of the annotated tag instead of the ID of the tagged commit. This fix peels the tag ref before using it as the starting point for the newly created branch. Bug: 340836 Change-Id: I01c7325770ecb37f5bf8ddb2a22f802466524f24 Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
index 7464a5ea3b..7760ec02d9 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
@@ -60,12 +60,14 @@ import org.eclipse.jgit.api.errors.NotMergedException;
import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefUpdate;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevTag;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
@@ -248,6 +250,28 @@ public class BranchCommandTest extends RepositoryTestCase {
}
@Test
+ public void testCreateFromLightweightTag() throws Exception {
+ RefUpdate rup = db.updateRef("refs/tags/V10");
+ rup.setNewObjectId(initialCommit);
+ rup.setExpectedOldObjectId(ObjectId.zeroId());
+ rup.update();
+
+ Ref branch = git.branchCreate().setName("FromLightweightTag")
+ .setStartPoint("refs/tags/V10").call();
+ assertEquals(initialCommit.getId(), branch.getObjectId());
+
+ }
+
+ @Test
+ public void testCreateFromAnnotatetdTag() throws Exception {
+ RevTag tag = git.tag().setName("V10").setObjectId(secondCommit).call();
+ Ref branch = git.branchCreate().setName("FromAnnotatedTag")
+ .setStartPoint("refs/tags/V10").call();
+ assertFalse(tag.getId().equals(branch.getObjectId()));
+ assertEquals(secondCommit.getId(), branch.getObjectId());
+ }
+
+ @Test
public void testDelete() throws Exception {
createBranch(git, "ForDelete", false, "master", null);
git.branchDelete().setBranchNames("ForDelete").call();