commit - 67606321850286a3a613541da555fd6642abaccd
commit + a19581a24bec8161b09eab50d721edc1c8f42be9
blob - 60c024909bd661ac5ba3c006a17501e2ad3e1ed4
blob + 9268ff826f30da37420b9969e0b0283db36d0455
--- include/got_object.h
+++ include/got_object.h
const struct got_error *
got_object_open_as_tree(struct got_tree_object **,
struct got_repository *, struct got_object_id *);
+const struct got_error *
+got_object_open_as_blob(struct got_blob_object **,
+ struct got_repository *, struct got_object_id *, size_t);
const struct got_error *
got_object_open_by_path(struct got_object **, struct got_repository *,
blob - 530f08f012ebee6cb4dcacf2a20e838ee7f87618
blob + 3bf9f6042a612ec493d55e91c4bb3fe3b468552d
--- lib/object.c
+++ lib/object.c
free((*blob)->read_buf);
free(*blob);
*blob = NULL;
+ }
+ return err;
+}
+
+const struct got_error *
+got_object_open_as_blob(struct got_blob_object **blob,
+ struct got_repository *repo, struct got_object_id *id,
+ size_t blocksize)
+{
+ const struct got_error *err;
+ struct got_object *obj;
+
+ err = got_object_open(&obj, repo, id);
+ if (err)
+ return err;
+ if (got_object_get_type(obj) != GOT_OBJ_TYPE_BLOB) {
+ err = got_error(GOT_ERR_OBJ_TYPE);
+ goto done;
}
+
+ err = got_object_blob_open(blob, repo, obj, blocksize);
+done:
+ got_object_close(obj);
return err;
}