]> git.proxmox.com Git - libgit2.git/blame - src/object.h
New upstream version 0.27.7+dfsg.1
[libgit2.git] / src / object.h
CommitLineData
c6ac28fd 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
c6ac28fd
RB
3 *
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.
6 */
7#ifndef INCLUDE_object_h__
8#define INCLUDE_object_h__
9
eae0bfdc
PP
10#include "common.h"
11
3ef01e77
ET
12#include "repository.h"
13
22a19f5b
ET
14extern bool git_object__strict_input_validation;
15
c6ac28fd
RB
16/** Base git object for inheritance */
17struct git_object {
18 git_cached_obj cached;
19 git_repository *repo;
c6ac28fd
RB
20};
21
22/* fully free the object; internal method, DO NOT EXPORT */
23void git_object__free(void *object);
24
c6ac28fd
RB
25int git_object__from_odb_object(
26 git_object **object_out,
27 git_repository *repo,
28 git_odb_object *odb_obj,
29 git_otype type);
30
31int git_object__resolve_to_type(git_object **obj, git_otype type);
32
eae0bfdc
PP
33git_otype git_object_stringn2type(const char *str, size_t len);
34
c6ac28fd
RB
35int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header);
36
37void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
38
3ef01e77
ET
39bool git_object__is_valid(
40 git_repository *repo, const git_oid *id, git_otype expected_type);
7565dc65 41
6ddf533a
ET
42GIT_INLINE(git_otype) git_object__type_from_filemode(git_filemode_t mode)
43{
44 switch (mode) {
45 case GIT_FILEMODE_TREE:
46 return GIT_OBJ_TREE;
47 case GIT_FILEMODE_COMMIT:
48 return GIT_OBJ_COMMIT;
49 case GIT_FILEMODE_BLOB:
50 case GIT_FILEMODE_BLOB_EXECUTABLE:
51 case GIT_FILEMODE_LINK:
52 return GIT_OBJ_BLOB;
53 default:
54 return GIT_OBJ_BAD;
55 }
56}
57
c6ac28fd 58#endif