Gives client a way to access specified object from any pack where it is stored (this may be useful when an object is stored in more than 1 pack). Signed-off-by: Marek Zawirski <marek.zawirski@xxxxxxxxx> --- .../src/org/spearce/jgit/lib/Repository.java | 42 ++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index 3efe60b..64f93ff 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -48,6 +48,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.LinkedList; import java.util.Map; import org.spearce.jgit.errors.IncorrectObjectTypeException; @@ -292,6 +293,47 @@ public class Repository { } /** + * Open object in all packs containing specified object. + * + * @param objectId + * id of object to search for + * @param curs + * temporary working space associated with the calling thread. + * @return collection of loaders for this object, from all packs containing + * this object + * @throws IOException + */ + public Collection<PackedObjectLoader> openObjectInAllPacks( + final AnyObjectId objectId, final WindowCursor curs) + throws IOException { + Collection<PackedObjectLoader> result = new LinkedList<PackedObjectLoader>(); + openObjectInAllPacks(objectId, result, curs); + return result; + } + + /** + * Open object in all packs containing specified object. + * + * @param objectId + * id of object to search for + * @param resultLoaders + * result collection of loaders for this object, filled with + * loaders from all packs containing specified object + * @param curs + * temporary working space associated with the calling thread. + * @throws IOException + */ + void openObjectInAllPacks(final AnyObjectId objectId, + final Collection<PackedObjectLoader> resultLoaders, + final WindowCursor curs) throws IOException { + for (PackFile pack : packs) { + final PackedObjectLoader loader = pack.get(curs, objectId); + if (loader != null) + resultLoaders.add(loader); + } + } + + /** * @param id * SHA'1 of a blob * @return an {@link ObjectLoader} for accessing the data of a named blob -- 1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html