Browse Source

Remove Repository.toFile(ObjectId)

Not every type of Repository will be able to map an ObjectId into
a local file system path that stores that object's file contents.
Heck, its not even true for the FileRepository, as an object can
be stored in a pack file and not in its loose format.

Remove this from our public API, it was a mistake to publish it.

Change-Id: I20d1b8c39104023936e6d46a5b0d7ef39ff118e8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
8f46ee4870
  1. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/T0003_Basic.java
  2. 14
      org.eclipse.jgit/src/org/eclipse/jgit/lib/FileRepository.java
  3. 12
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

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

@ -365,8 +365,10 @@ public class T0003_Basic extends SampleDataRepositoryTestCase {
assertEquals(cmtid, c.getCommitId());
// Verify the commit we just wrote is in the correct format.
final XInputStream xis = new XInputStream(new FileInputStream(db
.toFile(cmtid)));
ObjectDatabase odb = db.getObjectDatabase();
assertTrue("is ObjectDirectory", odb instanceof ObjectDirectory);
final XInputStream xis = new XInputStream(new FileInputStream(
((ObjectDirectory) odb).fileFor(cmtid)));
try {
assertEquals(0x78, xis.readUInt8());
assertEquals(0x9c, xis.readUInt8());

14
org.eclipse.jgit/src/org/eclipse/jgit/lib/FileRepository.java

@ -380,20 +380,6 @@ public class FileRepository extends Repository {
return repoConfig;
}
/**
* Construct a filename where the loose object having a specified SHA-1
* should be stored. If the object is stored in a shared repository the path
* to the alternative repo will be returned. If the object is not yet store
* a usable path in this repo will be returned. It is assumed that callers
* will look for objects in a pack first.
*
* @param objectId
* @return suggested file name
*/
public File toFile(final AnyObjectId objectId) {
return objectDatabase.fileFor(objectId);
}
/**
* Objects known to exist but not expressed by {@link #getAllRefs()}.
* <p>

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

@ -173,18 +173,6 @@ public abstract class Repository {
return fs;
}
/**
* Construct a filename where the loose object having a specified SHA-1
* should be stored. If the object is stored in a shared repository the path
* to the alternative repo will be returned. If the object is not yet store
* a usable path in this repo will be returned. It is assumed that callers
* will look for objects in a pack first.
*
* @param objectId
* @return suggested file name
*/
public abstract File toFile(AnyObjectId objectId);
/**
* @param objectId
* @return true if the specified object is stored in this repo or any of the

Loading…
Cancel
Save