Browse Source

Use getObjectsDatabase().getDirectory() to find objects

Only the ObjectDirectory type of database knows where to find the
objects directory on the local filesystem, so defer to it whenever
we need to know where the objects reside.  Since this is the type
returned by FileRepository's getObjectDatabase() method, we mostly
don't have to do much other than use a slightly longer invocation.

Change-Id: Ie5f58132a6411b56c3acad73646ad169d78a0654
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
767fd314ad
  1. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConcurrentRepackTest.java
  2. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/PackWriterTest.java
  3. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SampleDataRepositoryTestCase.java
  4. 16
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConcurrentRepackTest.java

@ -245,7 +245,7 @@ public class ConcurrentRepackTest extends RepositoryTestCase {
}
private File fullPackFileName(final ObjectId name, final String suffix) {
final File packdir = new File(db.getObjectsDirectory(), "pack");
final File packdir = new File(db.getObjectDatabase().getDirectory(), "pack");
return new File(packdir, "pack-" + name.name() + suffix);
}

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/PackWriterTest.java

@ -238,7 +238,7 @@ public class PackWriterTest extends SampleDataRepositoryTestCase {
* @throws IOException
*/
public void testWritePack2DeltasCRC32Copy() throws IOException {
final File packDir = new File(db.getObjectsDirectory(), "pack");
final File packDir = new File(db.getObjectDatabase().getDirectory(), "pack");
final File crc32Pack = new File(packDir,
"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
final File crc32Idx = new File(packDir,

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/SampleDataRepositoryTestCase.java

@ -65,7 +65,7 @@ public abstract class SampleDataRepositoryTestCase extends RepositoryTestCase {
"pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa",
"pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
};
final File packDir = new File(db.getObjectsDirectory(), "pack");
final File packDir = new File(db.getObjectDatabase().getDirectory(), "pack");
for (String n : packs) {
copyFile(JGitTestUtil.getTestResourceFile(n + ".pack"), new File(packDir, n + ".pack"));
copyFile(JGitTestUtil.getTestResourceFile(n + ".idx"), new File(packDir, n + ".idx"));

16
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java

@ -106,7 +106,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(repo1Parent, r.getWorkTree());
assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
assertEqualsPath(new File(theDir, "objects"), r.getObjectsDirectory());
assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase().getDirectory());
}
/**
@ -127,7 +127,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(repo1Parent.getParentFile(), r.getWorkTree());
assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
assertEqualsPath(new File(theDir, "objects"), r.getObjectsDirectory());
assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase().getDirectory());
}
/**
@ -147,7 +147,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(repo1Parent, r.getWorkTree());
assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
assertEqualsPath(new File(theDir, "objects"), r.getObjectsDirectory());
assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase().getDirectory());
}
/**
@ -172,7 +172,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(workdir, r.getWorkTree());
assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
assertEqualsPath(new File(theDir, "objects"), r.getObjectsDirectory());
assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase().getDirectory());
}
/**
@ -197,7 +197,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(workdir, r.getWorkTree());
assertEqualsPath(new File(theDir, "index"), r.getIndexFile());
assertEqualsPath(new File(theDir, "objects"), r.getObjectsDirectory());
assertEqualsPath(new File(theDir, "objects"), r.getObjectDatabase().getDirectory());
}
/**
@ -211,7 +211,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
File repo1Parent = new File(trash.getParentFile(), "r1");
File indexFile = new File(trash, "idx");
File objDir = new File(trash, "../obj");
File altObjDir = db.getObjectsDirectory();
File altObjDir = db.getObjectDatabase().getDirectory();
Repository repo1initial = new FileRepository(new File(repo1Parent, Constants.DOT_GIT));
repo1initial.create();
repo1initial.close();
@ -225,7 +225,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEqualsPath(theDir, r.getDirectory());
assertEqualsPath(theDir.getParentFile(), r.getWorkTree());
assertEqualsPath(indexFile, r.getIndexFile());
assertEqualsPath(objDir, r.getObjectsDirectory());
assertEqualsPath(objDir, r.getObjectDatabase().getDirectory());
assertNotNull(r.mapCommit("6db9c2ebf75590eef973081736730a9ea169a0c4"));
// Must close or the default repo pack files created by this test gets
// locked via the alternate object directories on Windows.
@ -327,7 +327,7 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
public void test007_Open() throws IOException {
final FileRepository db2 = new FileRepository(db.getDirectory());
assertEquals(db.getDirectory(), db2.getDirectory());
assertEquals(db.getObjectsDirectory(), db2.getObjectsDirectory());
assertEquals(db.getObjectDatabase().getDirectory(), db2.getObjectDatabase().getDirectory());
assertNotSame(db.getConfig(), db2.getConfig());
}

Loading…
Cancel
Save