Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7565dc6

Browse files
author
Edward Thomson
committed
git_object__is_valid: simple object validity test
1 parent 22a19f5 commit 7565dc6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/object.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,20 @@ int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end
3030

3131
void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
3232

33+
GIT_INLINE(bool) git_object__is_valid(
34+
git_repository *repo, const git_oid *id, git_otype type)
35+
{
36+
git_object *obj = NULL;
37+
bool valid = true;
38+
39+
if (git_object__strict_input_validation) {
40+
if (git_object_lookup(&obj, repo, id, type) < 0)
41+
valid = false;
42+
43+
git_object_free(obj);
44+
}
45+
46+
return valid;
47+
}
48+
3349
#endif

0 commit comments

Comments
 (0)