]>
git.proxmox.com Git - libgit2.git/blob - include/git2/object.h
2 * This file is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2,
4 * as published by the Free Software Foundation.
6 * In addition to the permissions in the GNU General Public License,
7 * the authors give you unlimited permission to link the compiled
8 * version of this file into combinations with other programs,
9 * and to distribute those combinations without any restriction
10 * coming from the use of this file. (The General Public License
11 * restrictions do apply in other respects; for example, they cover
12 * modification of the file, and distribution when not linked into
13 * a combined executable.)
15 * This file is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; see the file COPYING. If not, write to
22 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
25 #ifndef INCLUDE_git_object_h__
26 #define INCLUDE_git_object_h__
34 * @brief Git revision object management routines
35 * @defgroup git_object Git revision object management routines
42 * Lookup a reference to one of the objects in a repostory.
44 * The generated reference is owned by the repository and
45 * should be closed with the `git_object_close` method
46 * instead of free'd manually.
48 * The 'type' parameter must match the type of the object
49 * in the odb; the method will fail otherwise.
50 * The special value 'GIT_OBJ_ANY' may be passed to let
51 * the method guess the object's type.
53 * @param object pointer to the looked-up object
54 * @param repo the repository to look up the object
55 * @param id the unique identifier for the object
56 * @param type the type of the object
57 * @return a reference to the object
59 GIT_EXTERN(int) git_object_lookup(git_object
**object
, git_repository
*repo
, const git_oid
*id
, git_otype type
);
62 * Get the id (SHA1) of a repository object
64 * @param obj the repository object
67 GIT_EXTERN(const git_oid
*) git_object_id(const git_object
*obj
);
70 * Get the object type of an object
72 * @param obj the repository object
73 * @return the object's type
75 GIT_EXTERN(git_otype
) git_object_type(const git_object
*obj
);
78 * Get the repository that owns this object
80 * @param obj the object
81 * @return the repository who owns this object
83 GIT_EXTERN(git_repository
*) git_object_owner(const git_object
*obj
);
86 * Close an open object
88 * This method instructs the library to close an existing
89 * object; note that git_objects are owned and cached by the repository
90 * so the object may or may not be freed after this library call,
91 * depending on how agressive is the caching mechanism used
95 * It *is* necessary to call this method when you stop using
96 * an object. Failure to do so will cause a memory leak.
98 * @param object the object to close
100 GIT_EXTERN(void) git_object_close(git_object
*object
);
103 * Convert an object type to it's string representation.
105 * The result is a pointer to a string in static memory and
106 * should not be free()'ed.
108 * @param type object type to convert.
109 * @return the corresponding string representation.
111 GIT_EXTERN(const char *) git_object_type2string(git_otype type
);
114 * Convert a string object type representation to it's git_otype.
116 * @param str the string to convert.
117 * @return the corresponding git_otype.
119 GIT_EXTERN(git_otype
) git_object_string2type(const char *str
);
122 * Determine if the given git_otype is a valid loose object type.
124 * @param type object type to test.
125 * @return true if the type represents a valid loose object type,
128 GIT_EXTERN(int) git_object_typeisloose(git_otype type
);
131 * Get the size in bytes for the structure which
132 * acts as an in-memory representation of any given
135 * For all the core types, this would the equivalent
136 * of calling `sizeof(git_commit)` if the core types
137 * were not opaque on the external API.
139 * @param type object type to get its size
140 * @return size in bytes of the object
142 GIT_EXTERN(size_t) git_object__size(git_otype type
);