Browse Source

Merge "Deprecate Repository#hasObject"

stable-5.3
Jonathan Nieder 6 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
752d5547e4
  1. 8
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java
  2. 8
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java
  3. 2
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java
  4. 12
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java
  5. 42
      org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java
  6. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBranchPrunedTest.java
  7. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java
  8. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcTagTest.java
  9. 8
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java
  10. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java
  11. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java
  12. 134
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
  13. 3
      org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
  14. 2
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  15. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java
  16. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
  17. 16
      org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java
  18. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java

8
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientDumbServerTest.java

@ -194,13 +194,13 @@ public class DumbClientDumbServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_Loose() throws Exception { public void testInitialClone_Loose() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, remoteURI)) { try (Transport t = Transport.open(dst, remoteURI)) {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -216,13 +216,13 @@ public class DumbClientDumbServerTest extends HttpTestCase {
new TestRepository<>(remoteRepository).packAndPrune(); new TestRepository<>(remoteRepository).packAndPrune();
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, remoteURI)) { try (Transport t = Transport.open(dst, remoteURI)) {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);

8
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/DumbClientSmartServerTest.java

@ -193,14 +193,14 @@ public class DumbClientSmartServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_Small() throws Exception { public void testInitialClone_Small() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, remoteURI)) { try (Transport t = Transport.open(dst, remoteURI)) {
((TransportHttp) t).setUseSmartHttp(false); ((TransportHttp) t).setUseSmartHttp(false);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -218,14 +218,14 @@ public class DumbClientSmartServerTest extends HttpTestCase {
new TestRepository<>(remoteRepository).packAndPrune(); new TestRepository<>(remoteRepository).packAndPrune();
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, remoteURI)) { try (Transport t = Transport.open(dst, remoteURI)) {
((TransportHttp) t).setUseSmartHttp(false); ((TransportHttp) t).setUseSmartHttp(false);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);

2
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/HookMessageTest.java

@ -163,7 +163,7 @@ public class HookMessageTest extends HttpTestCase {
.singleton(update)); .singleton(update));
} }
assertTrue(remoteRepository.hasObject(Q_txt)); assertTrue(remoteRepository.getObjectDatabase().has(Q_txt));
assertNotNull("has " + dstName, remoteRepository.exactRef(dstName)); assertNotNull("has " + dstName, remoteRepository.exactRef(dstName));
assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId()); assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId());
fsck(remoteRepository, Q); fsck(remoteRepository, Q);

12
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerSslTest.java

@ -275,13 +275,13 @@ public class SmartClientSmartServerSslTest extends HttpTestCase {
@Test @Test
public void testInitialClone_ViaHttps() throws Exception { public void testInitialClone_ViaHttps() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, secureURI)) { try (Transport t = Transport.open(dst, secureURI)) {
t.setCredentialsProvider(testCredentials); t.setCredentialsProvider(testCredentials);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -292,14 +292,14 @@ public class SmartClientSmartServerSslTest extends HttpTestCase {
@Test @Test
public void testInitialClone_RedirectToHttps() throws Exception { public void testInitialClone_RedirectToHttps() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(remoteURI, "/https"); URIish cloneFrom = extendPath(remoteURI, "/https");
try (Transport t = Transport.open(dst, cloneFrom)) { try (Transport t = Transport.open(dst, cloneFrom)) {
t.setCredentialsProvider(testCredentials); t.setCredentialsProvider(testCredentials);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -310,7 +310,7 @@ public class SmartClientSmartServerSslTest extends HttpTestCase {
@Test @Test
public void testInitialClone_RedirectBackToHttp() throws Exception { public void testInitialClone_RedirectBackToHttp() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(secureURI, "/back"); URIish cloneFrom = extendPath(secureURI, "/back");
try (Transport t = Transport.open(dst, cloneFrom)) { try (Transport t = Transport.open(dst, cloneFrom)) {
@ -325,7 +325,7 @@ public class SmartClientSmartServerSslTest extends HttpTestCase {
@Test @Test
public void testInitialClone_SslFailure() throws Exception { public void testInitialClone_SslFailure() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, secureURI)) { try (Transport t = Transport.open(dst, secureURI)) {
// Set a credentials provider that doesn't handle questions // Set a credentials provider that doesn't handle questions

42
org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java

@ -455,13 +455,13 @@ public class SmartClientSmartServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_Small() throws Exception { public void testInitialClone_Small() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, remoteURI)) { try (Transport t = Transport.open(dst, remoteURI)) {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -495,7 +495,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
private void initialClone_Redirect(int nofRedirects, int code) private void initialClone_Redirect(int nofRedirects, int code)
throws Exception { throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = redirectURI; URIish cloneFrom = redirectURI;
if (code != 301 || nofRedirects > 1) { if (code != 301 || nofRedirects > 1) {
@ -506,7 +506,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -584,7 +584,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
userConfig.setInt("http", null, "maxRedirects", 3); userConfig.setInt("http", null, "maxRedirects", 3);
userConfig.save(); userConfig.save();
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(redirectURI, "/response/4/302"); URIish cloneFrom = extendPath(redirectURI, "/response/4/302");
String remoteUri = cloneFrom.toString(); String remoteUri = cloneFrom.toString();
@ -606,7 +606,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_RedirectLoop() throws Exception { public void testInitialClone_RedirectLoop() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(redirectURI, "/loop"); URIish cloneFrom = extendPath(redirectURI, "/loop");
try (Transport t = Transport.open(dst, cloneFrom)) { try (Transport t = Transport.open(dst, cloneFrom)) {
@ -624,14 +624,14 @@ public class SmartClientSmartServerTest extends HttpTestCase {
userConfig.setString("http", null, "followRedirects", "true"); userConfig.setString("http", null, "followRedirects", "true");
userConfig.save(); userConfig.save();
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(remoteURI, "/post"); URIish cloneFrom = extendPath(remoteURI, "/post");
try (Transport t = Transport.open(dst, cloneFrom)) { try (Transport t = Transport.open(dst, cloneFrom)) {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -669,7 +669,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_RedirectOnPostForbidden() throws Exception { public void testInitialClone_RedirectOnPostForbidden() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(remoteURI, "/post"); URIish cloneFrom = extendPath(remoteURI, "/post");
try (Transport t = Transport.open(dst, cloneFrom)) { try (Transport t = Transport.open(dst, cloneFrom)) {
@ -688,7 +688,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
userConfig.save(); userConfig.save();
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, redirectURI)) { try (Transport t = Transport.open(dst, redirectURI)) {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
@ -702,14 +702,14 @@ public class SmartClientSmartServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_WithAuthentication() throws Exception { public void testInitialClone_WithAuthentication() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, authURI)) { try (Transport t = Transport.open(dst, authURI)) {
t.setCredentialsProvider(testCredentials); t.setCredentialsProvider(testCredentials);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -748,7 +748,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
public void testInitialClone_WithAuthenticationNoCredentials() public void testInitialClone_WithAuthenticationNoCredentials()
throws Exception { throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, authURI)) { try (Transport t = Transport.open(dst, authURI)) {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
@ -770,7 +770,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
public void testInitialClone_WithAuthenticationWrongCredentials() public void testInitialClone_WithAuthenticationWrongCredentials()
throws Exception { throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, authURI)) { try (Transport t = Transport.open(dst, authURI)) {
t.setCredentialsProvider(new UsernamePasswordCredentialsProvider( t.setCredentialsProvider(new UsernamePasswordCredentialsProvider(
@ -796,7 +796,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
public void testInitialClone_WithAuthenticationAfterRedirect() public void testInitialClone_WithAuthenticationAfterRedirect()
throws Exception { throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
URIish cloneFrom = extendPath(redirectURI, "/target/auth"); URIish cloneFrom = extendPath(redirectURI, "/target/auth");
CredentialsProvider uriSpecificCredentialsProvider = new UsernamePasswordCredentialsProvider( CredentialsProvider uriSpecificCredentialsProvider = new UsernamePasswordCredentialsProvider(
@ -820,7 +820,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -865,14 +865,14 @@ public class SmartClientSmartServerTest extends HttpTestCase {
public void testInitialClone_WithAuthenticationOnPostOnly() public void testInitialClone_WithAuthenticationOnPostOnly()
throws Exception { throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, authOnPostURI)) { try (Transport t = Transport.open(dst, authOnPostURI)) {
t.setCredentialsProvider(testCredentials); t.setCredentialsProvider(testCredentials);
t.fetch(NullProgressMonitor.INSTANCE, mirror(master)); t.fetch(NullProgressMonitor.INSTANCE, mirror(master));
} }
assertTrue(dst.hasObject(A_txt)); assertTrue(dst.getObjectDatabase().has(A_txt));
assertEquals(B, dst.exactRef(master).getObjectId()); assertEquals(B, dst.exactRef(master).getObjectId());
fsck(dst, B); fsck(dst, B);
@ -1042,7 +1042,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
@Test @Test
public void testInitialClone_BrokenServer() throws Exception { public void testInitialClone_BrokenServer() throws Exception {
Repository dst = createBareRepository(); Repository dst = createBareRepository();
assertFalse(dst.hasObject(A_txt)); assertFalse(dst.getObjectDatabase().has(A_txt));
try (Transport t = Transport.open(dst, brokenURI)) { try (Transport t = Transport.open(dst, brokenURI)) {
try { try {
@ -1201,7 +1201,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
t.push(NullProgressMonitor.INSTANCE, Collections.singleton(u)); t.push(NullProgressMonitor.INSTANCE, Collections.singleton(u));
} }
assertTrue(remoteRepository.hasObject(Q_txt)); assertTrue(remoteRepository.getObjectDatabase().has(Q_txt));
assertNotNull("has " + dstName, remoteRepository.exactRef(dstName)); assertNotNull("has " + dstName, remoteRepository.exactRef(dstName));
assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId()); assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId());
fsck(remoteRepository, Q); fsck(remoteRepository, Q);
@ -1275,7 +1275,7 @@ public class SmartClientSmartServerTest extends HttpTestCase {
t.push(NullProgressMonitor.INSTANCE, Collections.singleton(u)); t.push(NullProgressMonitor.INSTANCE, Collections.singleton(u));
} }
assertTrue(remoteRepository.hasObject(Q_bin)); assertTrue(remoteRepository.getObjectDatabase().has(Q_bin));
assertNotNull("has " + dstName, remoteRepository.exactRef(dstName)); assertNotNull("has " + dstName, remoteRepository.exactRef(dstName));
assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId()); assertEquals(Q, remoteRepository.exactRef(dstName).getObjectId());
fsck(remoteRepository, Q); fsck(remoteRepository, Q);

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBranchPrunedTest.java

@ -66,11 +66,11 @@ public class GcBranchPrunedTest extends GcTestCase {
fsTick(); fsTick();
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
do { do {
assertTrue(repo.hasObject(tip)); assertTrue(repo.getObjectDatabase().has(tip));
tr.parseBody(tip); tr.parseBody(tip);
RevTree t = tip.getTree(); RevTree t = tip.getTree();
assertTrue(repo.hasObject(t)); assertTrue(repo.getObjectDatabase().has(t));
assertTrue(repo.hasObject(tr.get(t, "a"))); assertTrue(repo.getObjectDatabase().has(tr.get(t, "a")));
tip = tip.getParentCount() > 0 ? tip.getParent(0) : null; tip = tip.getParentCount() > 0 ? tip.getParent(0) : null;
} while (tip != null); } while (tip != null);
} }
@ -114,6 +114,6 @@ public class GcBranchPrunedTest extends GcTestCase {
gc.setExpireAgeMillis(0); gc.setExpireAgeMillis(0);
fsTick(); fsTick();
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertTrue(repo.hasObject(b2Tip)); assertTrue(repo.getObjectDatabase().has(b2Tip));
} }
} }

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcPruneNonReferencedTest.java

@ -63,7 +63,7 @@ public class GcPruneNonReferencedTest extends GcTestCase {
RevBlob a = tr.blob("a"); RevBlob a = tr.blob("a");
gc.setExpire(new Date(lastModified(a))); gc.setExpire(new Date(lastModified(a)));
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertTrue(repo.hasObject(a)); assertTrue(repo.getObjectDatabase().has(a));
} }
@Test @Test
@ -72,7 +72,7 @@ public class GcPruneNonReferencedTest extends GcTestCase {
gc.setExpireAgeMillis(0); gc.setExpireAgeMillis(0);
fsTick(); fsTick();
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertFalse(repo.hasObject(a)); assertFalse(repo.getObjectDatabase().has(a));
} }
@Test @Test
@ -82,8 +82,8 @@ public class GcPruneNonReferencedTest extends GcTestCase {
gc.setExpireAgeMillis(0); gc.setExpireAgeMillis(0);
fsTick(); fsTick();
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertFalse(repo.hasObject(t)); assertFalse(repo.getObjectDatabase().has(t));
assertFalse(repo.hasObject(a)); assertFalse(repo.getObjectDatabase().has(a));
} }
@Test @Test
@ -95,8 +95,8 @@ public class GcPruneNonReferencedTest extends GcTestCase {
RevBlob b = tr.blob("b"); RevBlob b = tr.blob("b");
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertFalse(repo.hasObject(a)); assertFalse(repo.getObjectDatabase().has(a));
assertTrue(repo.hasObject(b)); assertTrue(repo.getObjectDatabase().has(b));
} }
@Test @Test

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcTagTest.java

@ -60,7 +60,7 @@ public class GcTagTest extends GcTestCase {
gc.setExpireAgeMillis(0); gc.setExpireAgeMillis(0);
fsTick(); fsTick();
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertTrue(repo.hasObject(a)); assertTrue(repo.getObjectDatabase().has(a));
} }
@Test @Test
@ -72,7 +72,7 @@ public class GcTagTest extends GcTestCase {
gc.setExpireAgeMillis(0); gc.setExpireAgeMillis(0);
fsTick(); fsTick();
gc.prune(Collections.<ObjectId> emptySet()); gc.prune(Collections.<ObjectId> emptySet());
assertTrue(repo.hasObject(t)); assertTrue(repo.getObjectDatabase().has(t));
assertTrue(repo.hasObject(a)); assertTrue(repo.getObjectDatabase().has(a));
} }
} }

8
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ObjectDirectoryTest.java

@ -126,7 +126,7 @@ public class ObjectDirectoryTest extends RepositoryTestCase {
// scanning of the packs directory // scanning of the packs directory
ObjectId id = commitFile("file.txt", "test", "master").getId(); ObjectId id = commitFile("file.txt", "test", "master").getId();
gc.gc(); gc.gc();
assertFalse(receivingDB.hasObject(unknownID)); assertFalse(receivingDB.getObjectDatabase().has(unknownID));
assertTrue(receivingDB.getObjectDatabase().hasPackedObject(id)); assertTrue(receivingDB.getObjectDatabase().hasPackedObject(id));
// preparations // preparations
@ -150,7 +150,7 @@ public class ObjectDirectoryTest extends RepositoryTestCase {
// JGit will not rescan the packs folder later on and fails to see // JGit will not rescan the packs folder later on and fails to see
// the pack file created during gc. // the pack file created during gc.
assertTrue(tmpFile.createNewFile()); assertTrue(tmpFile.createNewFile());
assertFalse(receivingDB.hasObject(unknownID)); assertFalse(receivingDB.getObjectDatabase().has(unknownID));
// trigger a gc. This will create packfiles which have likely the // trigger a gc. This will create packfiles which have likely the
// same mtime than the packfolder // same mtime than the packfolder
@ -177,8 +177,8 @@ public class ObjectDirectoryTest extends RepositoryTestCase {
Assume.assumeTrue(tmpFile.lastModified() == ret[0].lastModified()); Assume.assumeTrue(tmpFile.lastModified() == ret[0].lastModified());
// all objects are in a new packfile but we will not detect it // all objects are in a new packfile but we will not detect it
assertFalse(receivingDB.hasObject(unknownID)); assertFalse(receivingDB.getObjectDatabase().has(unknownID));
assertTrue(receivingDB.hasObject(id2)); assertTrue(receivingDB.getObjectDatabase().has(id2));
} }
} }

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PackParserTest.java

@ -163,7 +163,7 @@ public class PackParserTest extends RepositoryTestCase {
public void testPackWithDuplicateBlob() throws Exception { public void testPackWithDuplicateBlob() throws Exception {
final byte[] data = Constants.encode("0123456789abcdefg"); final byte[] data = Constants.encode("0123456789abcdefg");
TestRepository<Repository> d = new TestRepository<>(db); TestRepository<Repository> d = new TestRepository<>(db);
assertTrue(db.hasObject(d.blob(data))); assertTrue(db.getObjectDatabase().has(d.blob(data)));
TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024); TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
packHeader(pack, 1); packHeader(pack, 1);

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/ReceivePackAdvertiseRefsHookTest.java

@ -236,7 +236,7 @@ public class ReceivePackAdvertiseRefsHookTest extends LocalDiskRepositoryTestCas
// Verify the only storage of b is our packed delta above. // Verify the only storage of b is our packed delta above.
// //
ObjectDirectory od = (ObjectDirectory) src.getObjectDatabase(); ObjectDirectory od = (ObjectDirectory) src.getObjectDatabase();
assertTrue("has b", src.hasObject(b)); assertTrue("has b", od.has(b));
assertFalse("b not loose", od.fileFor(b).exists()); assertFalse("b not loose", od.fileFor(b).exists());
// Now use b but in a different commit than what is hidden. // Now use b but in a different commit than what is hidden.

134
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java

@ -128,13 +128,13 @@ public class UploadPackTest {
}, null); }, null);
uri = testProtocol.register(ctx, server); uri = testProtocol.register(ctx, server);
assertFalse(client.hasObject(commit0.toObjectId())); assertFalse(client.getObjectDatabase().has(commit0.toObjectId()));
// Fetch of the parent of the shallow commit // Fetch of the parent of the shallow commit
try (Transport tn = testProtocol.open(uri, client, "server")) { try (Transport tn = testProtocol.open(uri, client, "server")) {
tn.fetch(NullProgressMonitor.INSTANCE, tn.fetch(NullProgressMonitor.INSTANCE,
Collections.singletonList(new RefSpec(commit0.name()))); Collections.singletonList(new RefSpec(commit0.name())));
assertTrue(client.hasObject(commit0.toObjectId())); assertTrue(client.getObjectDatabase().has(commit0.toObjectId()));
} }
} }
@ -147,7 +147,7 @@ public class UploadPackTest {
testProtocol = generateReachableCommitUploadPackProtocol(); testProtocol = generateReachableCommitUploadPackProtocol();
uri = testProtocol.register(ctx, server); uri = testProtocol.register(ctx, server);
assertFalse(client.hasObject(blob.toObjectId())); assertFalse(client.getObjectDatabase().has(blob.toObjectId()));
try (Transport tn = testProtocol.open(uri, client, "server")) { try (Transport tn = testProtocol.open(uri, client, "server")) {
thrown.expect(TransportException.class); thrown.expect(TransportException.class);
@ -168,12 +168,12 @@ public class UploadPackTest {
testProtocol = generateReachableCommitUploadPackProtocol(); testProtocol = generateReachableCommitUploadPackProtocol();
uri = testProtocol.register(ctx, server); uri = testProtocol.register(ctx, server);
assertFalse(client.hasObject(blob.toObjectId())); assertFalse(client.getObjectDatabase().has(blob.toObjectId()));
try (Transport tn = testProtocol.open(uri, client, "server")) { try (Transport tn = testProtocol.open(uri, client, "server")) {
tn.fetch(NullProgressMonitor.INSTANCE, tn.fetch(NullProgressMonitor.INSTANCE,
Collections.singletonList(new RefSpec(blob.name()))); Collections.singletonList(new RefSpec(blob.name())));
assertTrue(client.hasObject(blob.toObjectId())); assertTrue(client.getObjectDatabase().has(blob.toObjectId()));
} }
} }
@ -186,7 +186,7 @@ public class UploadPackTest {
testProtocol = generateReachableCommitUploadPackProtocol(); testProtocol = generateReachableCommitUploadPackProtocol();
uri = testProtocol.register(ctx, server); uri = testProtocol.register(ctx, server);
assertFalse(client.hasObject(blob.toObjectId())); assertFalse(client.getObjectDatabase().has(blob.toObjectId()));
try (Transport tn = testProtocol.open(uri, client, "server")) { try (Transport tn = testProtocol.open(uri, client, "server")) {
thrown.expect(TransportException.class); thrown.expect(TransportException.class);
@ -227,9 +227,9 @@ public class UploadPackTest {
tn.setFilterBlobLimit(0); tn.setFilterBlobLimit(0);
tn.fetch(NullProgressMonitor.INSTANCE, tn.fetch(NullProgressMonitor.INSTANCE,
Collections.singletonList(new RefSpec(commit.name()))); Collections.singletonList(new RefSpec(commit.name())));
assertTrue(client.hasObject(tree.toObjectId())); assertTrue(client.getObjectDatabase().has(tree.toObjectId()));
assertFalse(client.hasObject(blob1.toObjectId())); assertFalse(client.getObjectDatabase().has(blob1.toObjectId()));
assertFalse(client.hasObject(blob2.toObjectId())); assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
} }
} }
@ -265,9 +265,9 @@ public class UploadPackTest {
tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList( tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList(
new RefSpec(commit.name()), new RefSpec(commit.name()),
new RefSpec(blob1.name()))); new RefSpec(blob1.name())));
assertTrue(client.hasObject(tree.toObjectId())); assertTrue(client.getObjectDatabase().has(tree.toObjectId()));
assertTrue(client.hasObject(blob1.toObjectId())); assertTrue(client.getObjectDatabase().has(blob1.toObjectId()));
assertFalse(client.hasObject(blob2.toObjectId())); assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
} }
} }
@ -301,8 +301,8 @@ public class UploadPackTest {
tn.setFilterBlobLimit(5); tn.setFilterBlobLimit(5);
tn.fetch(NullProgressMonitor.INSTANCE, tn.fetch(NullProgressMonitor.INSTANCE,
Collections.singletonList(new RefSpec(commit.name()))); Collections.singletonList(new RefSpec(commit.name())));
assertFalse(client.hasObject(longBlob.toObjectId())); assertFalse(client.getObjectDatabase().has(longBlob.toObjectId()));
assertTrue(client.hasObject(shortBlob.toObjectId())); assertTrue(client.getObjectDatabase().has(shortBlob.toObjectId()));
} }
} }
@ -342,8 +342,8 @@ public class UploadPackTest {
tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList( tn.fetch(NullProgressMonitor.INSTANCE, Arrays.asList(
new RefSpec(commit.name()), new RefSpec(commit.name()),
new RefSpec(blob1.name()))); new RefSpec(blob1.name())));
assertTrue(client.hasObject(blob1.toObjectId())); assertTrue(client.getObjectDatabase().has(blob1.toObjectId()));
assertFalse(client.hasObject(blob2.toObjectId())); assertFalse(client.getObjectDatabase().has(blob2.toObjectId()));
} }
} }
@ -381,8 +381,8 @@ public class UploadPackTest {
tn.setFilterBlobLimit(5); tn.setFilterBlobLimit(5);
tn.fetch(NullProgressMonitor.INSTANCE, tn.fetch(NullProgressMonitor.INSTANCE,
Collections.singletonList(new RefSpec(commit.name()))); Collections.singletonList(new RefSpec(commit.name())));
assertFalse(client.hasObject(longBlob.toObjectId())); assertFalse(client.getObjectDatabase().has(longBlob.toObjectId()));
assertTrue(client.hasObject(shortBlob.toObjectId())); assertTrue(client.getObjectDatabase().has(shortBlob.toObjectId()));
} }
} }
@ -965,10 +965,10 @@ public class UploadPackTest {
assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM)); assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertFalse(client.hasObject(fooParent.toObjectId())); assertFalse(client.getObjectDatabase().has(fooParent.toObjectId()));
assertTrue(client.hasObject(fooChild.toObjectId())); assertTrue(client.getObjectDatabase().has(fooChild.toObjectId()));
assertFalse(client.hasObject(barParent.toObjectId())); assertFalse(client.getObjectDatabase().has(barParent.toObjectId()));
assertTrue(client.hasObject(barChild.toObjectId())); assertTrue(client.getObjectDatabase().has(barChild.toObjectId()));
} }
@Test @Test
@ -992,10 +992,10 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertFalse(client.hasObject(fooParent.toObjectId())); assertFalse(client.getObjectDatabase().has(fooParent.toObjectId()));
assertTrue(client.hasObject(fooChild.toObjectId())); assertTrue(client.getObjectDatabase().has(fooChild.toObjectId()));
assertTrue(client.hasObject(barParent.toObjectId())); assertTrue(client.getObjectDatabase().has(barParent.toObjectId()));
assertTrue(client.hasObject(barChild.toObjectId())); assertTrue(client.getObjectDatabase().has(barChild.toObjectId()));
} }
@Test @Test
@ -1078,7 +1078,7 @@ public class UploadPackTest {
PacketLineIn pckIn = new PacketLineIn(recvStream); PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertFalse(client.hasObject(tag.toObjectId())); assertFalse(client.getObjectDatabase().has(tag.toObjectId()));
// With tag. // With tag.
recvStream = uploadPackV2( recvStream = uploadPackV2(
@ -1091,7 +1091,7 @@ public class UploadPackTest {
pckIn = new PacketLineIn(recvStream); pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(tag.toObjectId())); assertTrue(client.getObjectDatabase().has(tag.toObjectId()));
} }
@Test @Test
@ -1149,8 +1149,8 @@ public class UploadPackTest {
PacketLineIn pckIn = new PacketLineIn(recvStream); PacketLineIn pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(barChild.toObjectId())); assertTrue(client.getObjectDatabase().has(barChild.toObjectId()));
assertFalse(client.hasObject(commonParent.toObjectId())); assertFalse(client.getObjectDatabase().has(commonParent.toObjectId()));
// With shallow, the server knows that we don't have // With shallow, the server knows that we don't have
// commonParent, so it sends it. // commonParent, so it sends it.
@ -1165,7 +1165,7 @@ public class UploadPackTest {
pckIn = new PacketLineIn(recvStream); pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(commonParent.toObjectId())); assertTrue(client.getObjectDatabase().has(commonParent.toObjectId()));
} }
@Test @Test
@ -1188,8 +1188,8 @@ public class UploadPackTest {
assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM)); assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(child.toObjectId())); assertTrue(client.getObjectDatabase().has(child.toObjectId()));
assertFalse(client.hasObject(parent.toObjectId())); assertFalse(client.getObjectDatabase().has(parent.toObjectId()));
// Without that, the parent is sent too. // Without that, the parent is sent too.
recvStream = uploadPackV2( recvStream = uploadPackV2(
@ -1201,7 +1201,7 @@ public class UploadPackTest {
pckIn = new PacketLineIn(recvStream); pckIn = new PacketLineIn(recvStream);
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(parent.toObjectId())); assertTrue(client.getObjectDatabase().has(parent.toObjectId()));
} }
@Test @Test
@ -1268,15 +1268,15 @@ public class UploadPackTest {
// The server does not send this because it is committed // The server does not send this because it is committed
// earlier than the given deepen-since time. // earlier than the given deepen-since time.
assertFalse(client.hasObject(tooOld.toObjectId())); assertFalse(client.getObjectDatabase().has(tooOld.toObjectId()));
// The server does not send this because the client claims to // The server does not send this because the client claims to
// have it. // have it.
assertFalse(client.hasObject(boundary.toObjectId())); assertFalse(client.getObjectDatabase().has(boundary.toObjectId()));
// The server sends both these commits. // The server sends both these commits.
assertTrue(client.hasObject(beyondBoundary.toObjectId())); assertTrue(client.getObjectDatabase().has(beyondBoundary.toObjectId()));
assertTrue(client.hasObject(merge.toObjectId())); assertTrue(client.getObjectDatabase().has(merge.toObjectId()));
} }
@Test @Test
@ -1316,9 +1316,9 @@ public class UploadPackTest {
parsePack(recvStream); parsePack(recvStream);
// Only the children are sent. // Only the children are sent.
assertFalse(client.hasObject(base.toObjectId())); assertFalse(client.getObjectDatabase().has(base.toObjectId()));
assertTrue(client.hasObject(child1.toObjectId())); assertTrue(client.getObjectDatabase().has(child1.toObjectId()));
assertTrue(client.hasObject(child2.toObjectId())); assertTrue(client.getObjectDatabase().has(child2.toObjectId()));
} }
@Test @Test
@ -1384,16 +1384,16 @@ public class UploadPackTest {
// The server does not send these because they are excluded by // The server does not send these because they are excluded by
// deepen-not. // deepen-not.
assertFalse(client.hasObject(side.toObjectId())); assertFalse(client.getObjectDatabase().has(side.toObjectId()));
assertFalse(client.hasObject(one.toObjectId())); assertFalse(client.getObjectDatabase().has(one.toObjectId()));
// The server does not send this because the client claims to // The server does not send this because the client claims to
// have it. // have it.
assertFalse(client.hasObject(three.toObjectId())); assertFalse(client.getObjectDatabase().has(three.toObjectId()));
// The server sends both these commits. // The server sends both these commits.
assertTrue(client.hasObject(merge.toObjectId())); assertTrue(client.getObjectDatabase().has(merge.toObjectId()));
assertTrue(client.hasObject(two.toObjectId())); assertTrue(client.getObjectDatabase().has(two.toObjectId()));
} }
@Test @Test
@ -1441,10 +1441,10 @@ public class UploadPackTest {
assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM)); assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertFalse(client.hasObject(one.toObjectId())); assertFalse(client.getObjectDatabase().has(one.toObjectId()));
assertFalse(client.hasObject(two.toObjectId())); assertFalse(client.getObjectDatabase().has(two.toObjectId()));
assertTrue(client.hasObject(three.toObjectId())); assertTrue(client.getObjectDatabase().has(three.toObjectId()));
assertTrue(client.hasObject(four.toObjectId())); assertTrue(client.getObjectDatabase().has(four.toObjectId()));
} }
@Test @Test
@ -1485,9 +1485,9 @@ public class UploadPackTest {
parsePack(recvStream); parsePack(recvStream);
// Only the children are sent. // Only the children are sent.
assertFalse(client.hasObject(base.toObjectId())); assertFalse(client.getObjectDatabase().has(base.toObjectId()));
assertTrue(client.hasObject(child1.toObjectId())); assertTrue(client.getObjectDatabase().has(child1.toObjectId()));
assertTrue(client.hasObject(child2.toObjectId())); assertTrue(client.getObjectDatabase().has(child2.toObjectId()));
} }
@Test @Test
@ -1538,8 +1538,8 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertFalse(client.hasObject(big.toObjectId())); assertFalse(client.getObjectDatabase().has(big.toObjectId()));
assertTrue(client.hasObject(small.toObjectId())); assertTrue(client.getObjectDatabase().has(small.toObjectId()));
} }
@Test @Test
@ -1610,9 +1610,9 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(one.toObjectId())); assertTrue(client.getObjectDatabase().has(one.toObjectId()));
assertTrue(client.hasObject(two.toObjectId())); assertTrue(client.getObjectDatabase().has(two.toObjectId()));
assertFalse(client.hasObject(three.toObjectId())); assertFalse(client.getObjectDatabase().has(three.toObjectId()));
} }
@Test @Test
@ -1666,9 +1666,9 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(one.toObjectId())); assertTrue(client.getObjectDatabase().has(one.toObjectId()));
assertTrue(client.hasObject(two.toObjectId())); assertTrue(client.getObjectDatabase().has(two.toObjectId()));
assertFalse(client.hasObject(three.toObjectId())); assertFalse(client.getObjectDatabase().has(three.toObjectId()));
} }
@Test @Test
@ -1699,7 +1699,7 @@ public class UploadPackTest {
// ... but the client does not need the object itself. // ... but the client does not need the object itself.
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertFalse(client.hasObject(one.toObjectId())); assertFalse(client.getObjectDatabase().has(one.toObjectId()));
} }
@Test @Test
@ -1728,8 +1728,8 @@ public class UploadPackTest {
assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM)); assertThat(pckIn.readString(), theInstance(PacketLineIn.DELIM));
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(child.toObjectId())); assertTrue(client.getObjectDatabase().has(child.toObjectId()));
assertFalse(client.hasObject(parent.toObjectId())); assertFalse(client.getObjectDatabase().has(parent.toObjectId()));
} }
@Test @Test
@ -1765,9 +1765,9 @@ public class UploadPackTest {
assertThat(pckIn.readString(), is("packfile")); assertThat(pckIn.readString(), is("packfile"));
parsePack(recvStream); parsePack(recvStream);
assertTrue(client.hasObject(one.toObjectId())); assertTrue(client.getObjectDatabase().has(one.toObjectId()));
assertTrue(client.hasObject(two.toObjectId())); assertTrue(client.getObjectDatabase().has(two.toObjectId()));
assertTrue(client.hasObject(three.toObjectId())); assertTrue(client.getObjectDatabase().has(three.toObjectId()));
} }
@Test @Test

3
org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java

@ -193,7 +193,8 @@ public class FetchCommand extends TransportCommand<FetchCommand, FetchResult> {
// updated to an object that is not currently present in the // updated to an object that is not currently present in the
// submodule. // submodule.
if ((recurseMode == FetchRecurseSubmodulesMode.ON_DEMAND if ((recurseMode == FetchRecurseSubmodulesMode.ON_DEMAND
&& !submoduleRepo.hasObject(walk.getObjectId())) && !submoduleRepo.getObjectDatabase()
.has(walk.getObjectId()))
|| recurseMode == FetchRecurseSubmodulesMode.YES) { || recurseMode == FetchRecurseSubmodulesMode.YES) {
FetchCommand f = new FetchCommand(submoduleRepo) FetchCommand f = new FetchCommand(submoduleRepo)
.setProgressMonitor(monitor) .setProgressMonitor(monitor)

2
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -319,7 +319,9 @@ public abstract class Repository implements AutoCloseable {
* a {@link org.eclipse.jgit.lib.AnyObjectId} object. * a {@link org.eclipse.jgit.lib.AnyObjectId} object.
* @return true if the specified object is stored in this repo or any of the * @return true if the specified object is stored in this repo or any of the
* known shared repositories. * known shared repositories.
* @deprecated use {@code getObjectDatabase().has(objectId)}
*/ */
@Deprecated
public boolean hasObject(AnyObjectId objectId) { public boolean hasObject(AnyObjectId objectId) {
try { try {
return getObjectDatabase().has(objectId); return getObjectDatabase().has(objectId);

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/BasePackPushConnection.java

@ -338,7 +338,7 @@ public abstract class BasePackPushConnection extends BasePackConnection implemen
for (Ref r : getRefs()) { for (Ref r : getRefs()) {
// only add objects that we actually have // only add objects that we actually have
ObjectId oid = r.getObjectId(); ObjectId oid = r.getObjectId();
if (local.hasObject(oid)) if (local.getObjectDatabase().has(oid))
remoteObjects.add(oid); remoteObjects.add(oid);
} }
remoteObjects.addAll(additionalHaves); remoteObjects.addAll(additionalHaves);

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

@ -1588,7 +1588,7 @@ public abstract class BaseReceivePack {
throw new MissingObjectException(o, o.getType()); throw new MissingObjectException(o, o.getType());
} }
if (o instanceof RevBlob && !db.hasObject(o)) if (o instanceof RevBlob && !db.getObjectDatabase().has(o))
throw new MissingObjectException(o, Constants.TYPE_BLOB); throw new MissingObjectException(o, Constants.TYPE_BLOB);
} }
checking.endTask(); checking.endTask();

16
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java

@ -181,7 +181,7 @@ class FetchProcess {
ObjectId id = r.getPeeledObjectId(); ObjectId id = r.getPeeledObjectId();
if (id == null) if (id == null)
id = r.getObjectId(); id = r.getObjectId();
if (transport.local.hasObject(id)) if (localHasObject(id))
wantTag(r); wantTag(r);
} }
@ -393,6 +393,18 @@ class FetchProcess {
} }
} }
private boolean localHasObject(ObjectId id) throws TransportException {
try {
return transport.local.getObjectDatabase().has(id);
} catch (IOException err) {
throw new TransportException(
MessageFormat.format(
JGitText.get().readingObjectsFromLocalRepositoryFailed,
err.getMessage()),
err);
}
}
private Collection<Ref> expandAutoFollowTags() throws TransportException { private Collection<Ref> expandAutoFollowTags() throws TransportException {
final Collection<Ref> additionalTags = new ArrayList<>(); final Collection<Ref> additionalTags = new ArrayList<>();
final Map<String, Ref> haveRefs = localRefs(); final Map<String, Ref> haveRefs = localRefs();
@ -410,7 +422,7 @@ class FetchProcess {
if (obj == null) if (obj == null)
obj = r.getObjectId(); obj = r.getObjectId();
if (askFor.containsKey(obj) || transport.local.hasObject(obj)) if (askFor.containsKey(obj) || localHasObject(obj))
wantTag(r); wantTag(r);
else else
additionalTags.add(r); additionalTags.add(r);

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java

@ -555,10 +555,10 @@ class WalkFetchConnection extends BaseFetchConnection {
continue; continue;
} finally { } finally {
// If the pack was good its in the local repository // If the pack was good its in the local repository
// and Repository.hasObject(id) will succeed in the // and Repository.getObjectDatabase().has(id) will
// future, so we do not need this data anymore. If // succeed in the future, so we do not need this
// it failed the index and pack are unusable and we // data any more. If it failed the index and pack
// shouldn't consult them again. // are unusable and we shouldn't consult them again.
// //
try { try {
if (pack.tmpIdx != null) if (pack.tmpIdx != null)

Loading…
Cancel
Save