diff options
author | Edward Thomson <ethomson@github.com> | 2016-02-23 13:33:10 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-02-28 12:38:39 -0500 |
commit | 7565dc6572e94ee10462169dd07ba8afe08388c7 (patch) | |
tree | 505411f45430e0b334b6f0d95db68901324ac884 | |
parent | 22a19f5b5795153b4c77c75adfae790c3b919be4 (diff) | |
download | libgit2-7565dc6572e94ee10462169dd07ba8afe08388c7.tar.gz |
git_object__is_valid: simple object validity test
-rw-r--r-- | src/object.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/object.h b/src/object.h index 358279a3d..782436017 100644 --- a/src/object.h +++ b/src/object.h @@ -30,4 +30,20 @@ int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid); +GIT_INLINE(bool) git_object__is_valid( + git_repository *repo, const git_oid *id, git_otype type) +{ + git_object *obj = NULL; + bool valid = true; + + if (git_object__strict_input_validation) { + if (git_object_lookup(&obj, repo, id, type) < 0) + valid = false; + + git_object_free(obj); + } + + return valid; +} + #endif |