aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
index 42c8a92b93..100b758e65 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2009-2010, Google Inc.
* Copyright (C) 2009, Robin Rosenberg
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
* and other copyright owners as documented in the project's IP log.
@@ -58,15 +59,26 @@ import org.eclipse.jgit.lib.RefUpdate.Result;
*/
public class RefTest extends SampleDataRepositoryTestCase {
+ private void writeSymref(String src, String dst) throws IOException {
+ RefUpdate u = db.updateRef(src);
+ switch (u.link(dst)) {
+ case NEW:
+ case FORCED:
+ case NO_CHANGE:
+ break;
+ default:
+ fail("link " + src + " to " + dst);
+ }
+ }
+
public void testReadAllIncludingSymrefs() throws Exception {
ObjectId masterId = db.resolve("refs/heads/master");
RefUpdate updateRef = db.updateRef("refs/remotes/origin/master");
updateRef.setNewObjectId(masterId);
updateRef.setForceUpdate(true);
updateRef.update();
- db
- .writeSymref("refs/remotes/origin/HEAD",
- "refs/remotes/origin/master");
+ writeSymref("refs/remotes/origin/HEAD",
+ "refs/remotes/origin/master");
ObjectId r = db.resolve("refs/remotes/origin/HEAD");
assertEquals(masterId, r);
@@ -85,7 +97,7 @@ public class RefTest extends SampleDataRepositoryTestCase {
}
public void testReadSymRefToPacked() throws IOException {
- db.writeSymref("HEAD", "refs/heads/b");
+ writeSymref("HEAD", "refs/heads/b");
Ref ref = db.getRef("HEAD");
assertEquals(Ref.Storage.LOOSE, ref.getStorage());
assertTrue("is symref", ref.isSymbolic());
@@ -102,7 +114,7 @@ public class RefTest extends SampleDataRepositoryTestCase {
Result update = updateRef.update();
assertEquals(Result.FORCED, update); // internal
- db.writeSymref("HEAD", "refs/heads/master");
+ writeSymref("HEAD", "refs/heads/master");
Ref ref = db.getRef("HEAD");
assertEquals(Ref.Storage.LOOSE, ref.getStorage());
ref = ref.getTarget();