diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2021-12-04 20:00:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-04 20:00:41 -0500 |
| commit | 12b53eb0318b0529514ad7e318de70b8325d43f2 (patch) | |
| tree | dcec3efee630f9c38e15433302e5c6faec65e517 /include/git2 | |
| parent | 6fdb1b2f55da9593576b096ee2eecce61995fb51 (diff) | |
| parent | 9f03ebd14b6beb00a9bed52c0568a13f8d5ebb08 (diff) | |
| download | libgit2-12b53eb0318b0529514ad7e318de70b8325d43f2.tar.gz | |
Merge pull request #6128 from libgit2/ethomson/object_validation
Introduce `git_object_rawcontent_is_valid`
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/object.h | 22 | ||||
| -rw-r--r-- | include/git2/signature.h | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/include/git2/object.h b/include/git2/object.h index 984dbb7ac..dbf480ed6 100644 --- a/include/git2/object.h +++ b/include/git2/object.h @@ -224,6 +224,28 @@ GIT_EXTERN(int) git_object_peel( */ GIT_EXTERN(int) git_object_dup(git_object **dest, git_object *source); +/** + * Analyzes a buffer of raw object content and determines its validity. + * Tree, commit, and tag objects will be parsed and ensured that they + * are valid, parseable content. (Blobs are always valid by definition.) + * An error message will be set with an informative message if the object + * is not valid. + * + * @warning This function is experimental and its signature may change in + * the future. + * + * @param valid Output pointer to set with validity of the object content + * @param buf The contents to validate + * @param len The length of the buffer + * @param type The type of the object in the buffer + * @return 0 on success or an error code + */ +GIT_EXTERN(int) git_object_rawcontent_is_valid( + int *valid, + const char *buf, + size_t len, + git_object_t type); + /** @} */ GIT_END_DECL diff --git a/include/git2/signature.h b/include/git2/signature.h index b14f3ea89..849998e66 100644 --- a/include/git2/signature.h +++ b/include/git2/signature.h @@ -71,7 +71,7 @@ GIT_EXTERN(int) git_signature_default(git_signature **out, git_repository *repo) * * @param out new signature * @param buf signature string - * @return 0 on success, or an error code + * @return 0 on success, GIT_EINVALID if the signature is not parseable, or an error code */ GIT_EXTERN(int) git_signature_from_buffer(git_signature **out, const char *buf); |
