summaryrefslogtreecommitdiff
path: root/src/object.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-10-13 13:11:35 +0200
committerPatrick Steinhardt <ps@pks.im>2018-06-22 09:50:07 +0200
commitca4db5f4a9e69a0ca7c22eda7656c5625582a2eb (patch)
tree46e1838025ef2962d2746d39aed441e2adc53c8f /src/object.h
parent73bd64110d16c06833f854a8178176355f249a61 (diff)
downloadlibgit2-ca4db5f4a9e69a0ca7c22eda7656c5625582a2eb.tar.gz
object: implement function to parse raw data
Now that we have implement functions to parse all git objects from raw data, we can implement a generic function `git_object__from_raw` to create a structure of type `git_object`. This allows us to parse and interpret objects from raw data without having to touch the ODB at all, which is especially useful for object verification prior to accepting them into the repository.
Diffstat (limited to 'src/object.h')
-rw-r--r--src/object.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/object.h b/src/object.h
index e46c9cafa..f5cbbf763 100644
--- a/src/object.h
+++ b/src/object.h
@@ -22,6 +22,17 @@ struct git_object {
/* fully free the object; internal method, DO NOT EXPORT */
void git_object__free(void *object);
+/*
+ * Parse object from raw data. Note that the resulting object is
+ * tied to the lifetime of the data, as some objects simply point
+ * into it.
+ */
+int git_object__from_raw(
+ git_object **object_out,
+ const char *data,
+ size_t size,
+ git_otype type);
+
int git_object__from_odb_object(
git_object **object_out,
git_repository *repo,