2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_object_h__
8 #define INCLUDE_object_h__
12 #include "repository.h"
14 #define GIT_OBJECT_SIZE_MAX UINT64_MAX
16 extern bool git_object__strict_input_validation
;
18 /** Base git object for inheritance */
20 git_cached_obj cached
;
24 /* fully free the object; internal method, DO NOT EXPORT */
25 void git_object__free(void *object
);
28 * Parse object from raw data. Note that the resulting object is
29 * tied to the lifetime of the data, as some objects simply point
32 int git_object__from_raw(
33 git_object
**object_out
,
38 int git_object__from_odb_object(
39 git_object
**object_out
,
41 git_odb_object
*odb_obj
,
44 int git_object__resolve_to_type(git_object
**obj
, git_object_t type
);
46 git_object_t
git_object_stringn2type(const char *str
, size_t len
);
48 int git_oid__parse(git_oid
*oid
, const char **buffer_out
, const char *buffer_end
, const char *header
);
50 void git_oid__writebuf(git_str
*buf
, const char *header
, const git_oid
*oid
);
52 bool git_object__is_valid(
53 git_repository
*repo
, const git_oid
*id
, git_object_t expected_type
);
55 GIT_INLINE(git_object_t
) git_object__type_from_filemode(git_filemode_t mode
)
58 case GIT_FILEMODE_TREE
:
59 return GIT_OBJECT_TREE
;
60 case GIT_FILEMODE_COMMIT
:
61 return GIT_OBJECT_COMMIT
;
62 case GIT_FILEMODE_BLOB
:
63 case GIT_FILEMODE_BLOB_EXECUTABLE
:
64 case GIT_FILEMODE_LINK
:
65 return GIT_OBJECT_BLOB
;
67 return GIT_OBJECT_INVALID
;