summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.test/tst
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2015-06-05 15:20:24 -0700
committerJonathan Nieder <jrn@google.com>2015-11-25 14:05:20 -0800
commit5be4814e38f2c3983dc27ac6d74f95f2d73ed400 (patch)
tree33847b9f7f772f397a7855000c972db652c9c699 /org.eclipse.jgit.http.test/tst
parent830117e761bddc182e4dc57150ca661976868203 (diff)
downloadjgit-5be4814e38f2c3983dc27ac6d74f95f2d73ed400.tar.gz
jgit-5be4814e38f2c3983dc27ac6d74f95f2d73ed400.zip
Repository: Introduce exactRef and findRef, deprecate getRef
The Repository class provides only one method to look up a ref by name, getRef. If I request refs/heads/master and that ref does not exist, getRef will look further in the search path: ref/refs/heads/master refs/heads/refs/heads/master refs/remotes/refs/heads/master This behavior is counterintuitive, needlessly inexpensive, and usually not what the caller expects. Allow callers to specify whether to use the search path by providing two separate methods: - exactRef, which looks up a ref when its exact name is known - findRef, which looks for a ref along the search path For backward compatibility, keep getRef as a deprecated synonym for findRef. This change introduces findRef and exactRef but does not update callers outside tests to use them yet. Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c Signed-off-by: Jonathan Nieder <jrn@google.com>
Diffstat (limited to 'org.eclipse.jgit.http.test/tst')
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java4
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java4
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java4
-rw-r--r--org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java18
4 files changed, 15 insertions, 15 deletions
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
index dec9b59f2d..362a09d64f 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
@@ -209,7 +209,7 @@ public class DumbClientDumbServerTest extends HttpTestCase {
}
assertTrue(dst.hasObject(A_txt));
- assertEquals(B, dst.getRef(master).getObjectId());
+ assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B);
List<AccessEvent> loose = getRequests(loose(remoteURI, A_txt));
@@ -234,7 +234,7 @@ public class DumbClientDumbServerTest extends HttpTestCase {
}
assertTrue(dst.hasObject(A_txt));
- assertEquals(B, dst.getRef(master).getObjectId());
+ assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B);
List<AccessEvent> req;
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
index e385b9538d..da3a09809b 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
@@ -225,7 +225,7 @@ public class DumbClientSmartServerTest extends HttpTestCase {
}
assertTrue(dst.hasObject(A_txt));
- assertEquals(B, dst.getRef(master).getObjectId());
+ assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B);
List<AccessEvent> loose = getRequests(loose(remoteURI, A_txt));
@@ -253,7 +253,7 @@ public class DumbClientSmartServerTest extends HttpTestCase {
}
assertTrue(dst.hasObject(A_txt));
- assertEquals(B, dst.getRef(master).getObjectId());
+ assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B);
List<AccessEvent> req;
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
index f1056f2d6a..d67c8173cb 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
@@ -164,8 +164,8 @@ public class HookMessageTest extends HttpTestCase {
}
assertTrue(remoteRepository.hasObject(Q_txt));
- assertNotNull("has " + dstName, remoteRepository.getRef(dstName));
- assertEquals(Q, remoteRepository.getRef(dstName).getObjectId());
+ assertNotNull("has " + dstName, remoteRepository.exactRef(dstName));
+ assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId());
fsck(remoteRepository, Q);
List<AccessEvent> requests = getRequests();
diff --git a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
index 1b6c552cef..9ca0789e29 100644
--- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
+++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
@@ -296,7 +296,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
}
assertTrue(dst.hasObject(A_txt));
- assertEquals(B, dst.getRef(master).getObjectId());
+ assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B);
List<AccessEvent> requests = getRequests();
@@ -337,7 +337,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
} finally {
t.close();
}
- assertEquals(B, dst.getRepository().getRef(master).getObjectId());
+ assertEquals(B, dst.getRepository().exactRef(master).getObjectId());
List<AccessEvent> cloneRequests = getRequests();
// Only create a few new commits.
@@ -358,7 +358,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
} finally {
t.close();
}
- assertEquals(Z, dst.getRepository().getRef(master).getObjectId());
+ assertEquals(Z, dst.getRepository().exactRef(master).getObjectId());
List<AccessEvent> requests = getRequests();
requests.removeAll(cloneRequests);
@@ -400,7 +400,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
} finally {
t.close();
}
- assertEquals(B, dst.getRepository().getRef(master).getObjectId());
+ assertEquals(B, dst.getRepository().exactRef(master).getObjectId());
List<AccessEvent> cloneRequests = getRequests();
// Force enough into the local client that enumeration will
@@ -424,7 +424,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
} finally {
t.close();
}
- assertEquals(Z, dst.getRepository().getRef(master).getObjectId());
+ assertEquals(Z, dst.getRepository().exactRef(master).getObjectId());
List<AccessEvent> requests = getRequests();
requests.removeAll(cloneRequests);
@@ -579,8 +579,8 @@ public class SmartClientSmartServerTest extends HttpTestCase {
}
assertTrue(remoteRepository.hasObject(Q_txt));
- assertNotNull("has " + dstName, remoteRepository.getRef(dstName));
- assertEquals(Q, remoteRepository.getRef(dstName).getObjectId());
+ assertNotNull("has " + dstName, remoteRepository.exactRef(dstName));
+ assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId());
fsck(remoteRepository, Q);
final ReflogReader log = remoteRepository.getReflogReader(dstName);
@@ -657,8 +657,8 @@ public class SmartClientSmartServerTest extends HttpTestCase {
}
assertTrue(remoteRepository.hasObject(Q_bin));
- assertNotNull("has " + dstName, remoteRepository.getRef(dstName));
- assertEquals(Q, remoteRepository.getRef(dstName).getObjectId());
+ assertNotNull("has " + dstName, remoteRepository.exactRef(dstName));
+ assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId());
fsck(remoteRepository, Q);
List<AccessEvent> requests = getRequests();