@NotNull private InputStream openAttributes(@NotNull ObjectReader reader, @Nullable ObjectId id) throws IOException { if (ObjectId.zeroId().equals(id)) { return new ByteArrayInputStream(new byte[0]); } return reader.open(id, Constants.OBJ_BLOB).openStream(); }
@NotNull public ConvertTask convertTask(@NotNull ObjectReader reader, @NotNull TaskKey key) throws IOException { switch (key.getType()) { case Simple: { if (!reader.has(key.getObjectId())) { return keepMissingTask(key.getObjectId()); } final RevObject revObject = new RevWalk(reader).parseAny(key.getObjectId()); if (revObject instanceof RevCommit) { return convertCommitTask((RevCommit) revObject); } if (revObject instanceof RevTree) { return convertTreeTask(reader, revObject, false); } if (revObject instanceof RevBlob) { return copyTask(reader, revObject); } if (revObject instanceof RevTag) { return convertTagTask((RevTag) revObject); } throw new IllegalStateException( "Unsupported object type: " + key + " (" + revObject.getClass().getName() + ")"); } case Root: { final RevObject revObject = new RevWalk(reader).parseAny(key.getObjectId()); if (revObject instanceof RevTree) { return convertTreeTask(reader, revObject, true); } throw new IllegalStateException( "Unsupported object type: " + key + " (" + revObject.getClass().getName() + ")"); } case Attribute: return createAttributesTask(reader, key.getObjectId()); case UploadLfs: return convertLfsTask(reader, key.getObjectId()); default: throw new IllegalStateException("Unknwon task key type: " + key.getType()); } }