]>
git.proxmox.com Git - libgit2.git/blob - include/git2/tag.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_tag_h__
26 #define INCLUDE_git_tag_h__
35 * @brief Git tag parsing routines
36 * @defgroup git_tag Git tag management
43 * Lookup a tag object from the repository.
45 * @param tag pointer to the looked up tag
46 * @param repo the repo to use when locating the tag.
47 * @param id identity of the tag to locate.
48 * @return 0 on success; error code otherwise
50 GIT_INLINE(int) git_tag_lookup(git_tag
**tag
, git_repository
*repo
, const git_oid
*id
)
52 return git_object_lookup((git_object
**)tag
, repo
, id
, (git_otype
)GIT_OBJ_TAG
);
56 * Lookup a tag object from the repository,
57 * given a prefix of its identifier (short id).
59 * @see git_object_lookup_prefix
61 * @param tag pointer to the looked up tag
62 * @param repo the repo to use when locating the tag.
63 * @param id identity of the tag to locate.
64 * @param len the length of the short identifier
65 * @return 0 on success; error code otherwise
67 GIT_INLINE(int) git_tag_lookup_prefix(git_tag
**tag
, git_repository
*repo
, const git_oid
*id
, unsigned int len
)
69 return git_object_lookup_prefix((git_object
**)tag
, repo
, id
, len
, (git_otype
)GIT_OBJ_TAG
);
75 * This is a wrapper around git_object_close()
78 * It *is* necessary to call this method when you stop
79 * using a tag. Failure to do so will cause a memory leak.
81 * @param tag the tag to close
84 GIT_INLINE(void) git_tag_close(git_tag
*tag
)
86 git_object_close((git_object
*) tag
);
91 * Get the id of a tag.
93 * @param tag a previously loaded tag.
94 * @return object identity for the tag.
96 GIT_EXTERN(const git_oid
*) git_tag_id(git_tag
*tag
);
99 * Get the tagged object of a tag
101 * This method performs a repository lookup for the
102 * given object and returns it
104 * @param target pointer where to store the target
105 * @param tag a previously loaded tag.
106 * @return 0 on success; error code otherwise
108 GIT_EXTERN(int) git_tag_target(git_object
**target
, git_tag
*t
);
111 * Get the OID of the tagged object of a tag
113 * @param tag a previously loaded tag.
114 * @return pointer to the OID
116 GIT_EXTERN(const git_oid
*) git_tag_target_oid(git_tag
*t
);
119 * Get the type of a tag's tagged object
121 * @param tag a previously loaded tag.
122 * @return type of the tagged object
124 GIT_EXTERN(git_otype
) git_tag_type(git_tag
*t
);
127 * Get the name of a tag
129 * @param tag a previously loaded tag.
130 * @return name of the tag
132 GIT_EXTERN(const char *) git_tag_name(git_tag
*t
);
135 * Get the tagger (author) of a tag
137 * @param tag a previously loaded tag.
138 * @return reference to the tag's author
140 GIT_EXTERN(const git_signature
*) git_tag_tagger(git_tag
*t
);
143 * Get the message of a tag
145 * @param tag a previously loaded tag.
146 * @return message of the tag
148 GIT_EXTERN(const char *) git_tag_message(git_tag
*t
);
152 * Create a new tag in the repository from an OID
154 * @param oid Pointer where to store the OID of the
155 * newly created tag. If the tag already exists, this parameter
156 * will be the oid of the existed tag, and the function will
157 * return a GIT_EEXISTS error code.
159 * @param repo Repository where to store the tag
161 * @param tag_name Name for the tag; this name is validated
162 * for consistency. It should also not conflict with an
163 * already existing tag name
165 * @param target OID to which this tag points; note that no
166 * validation is done on this OID. Use the _o version of this
167 * method to assure a proper object is being tagged
169 * @param target_type Type of the tagged OID; note that no
170 * validation is performed here either
172 * @param tagger Signature of the tagger for this tag, and
173 * of the tagging time
175 * @param message Full message for this tag
177 * @return 0 on success; error code otherwise.
178 * A tag object is written to the ODB, and a proper reference
179 * is written in the /refs/tags folder, pointing to it
181 GIT_EXTERN(int) git_tag_create(
183 git_repository
*repo
,
184 const char *tag_name
,
185 const git_oid
*target
,
186 git_otype target_type
,
187 const git_signature
*tagger
,
188 const char *message
);
192 * Create a new tag in the repository from an existing
193 * `git_object` instance
195 * This method replaces the `target` and `target_type`
196 * paremeters of `git_tag_create` by a single instance
197 * of a `const git_object *`, which is assured to be
198 * a proper object in the ODB and hence will create
201 * @see git_tag_create
203 GIT_EXTERN(int) git_tag_create_o(
205 git_repository
*repo
,
206 const char *tag_name
,
207 const git_object
*target
,
208 const git_signature
*tagger
,
209 const char *message
);
212 * Create a new tag in the repository from a buffer
214 * @param oid Pointer where to store the OID of the newly created tag
216 * @param repo Repository where to store the tag
218 * @param buffer Raw tag data
220 GIT_EXTERN(int) git_tag_create_frombuffer(
222 git_repository
*repo
,
226 * Create a new tag in the repository from an OID
227 * and overwrite an already existing tag reference, if any.
229 * @param oid Pointer where to store the OID of the
232 * @param repo Repository where to store the tag
234 * @param tag_name Name for the tag; this name is validated
237 * @param target OID to which this tag points; note that no
238 * validation is done on this OID. Use the _fo version of this
239 * method to assure a proper object is being tagged
241 * @param target_type Type of the tagged OID; note that no
242 * validation is performed here either
244 * @param tagger Signature of the tagger for this tag, and
245 * of the tagging time
247 * @param message Full message for this tag
249 * @return 0 on success; error code otherwise.
250 * A tag object is written to the ODB, and a proper reference
251 * is written in the /refs/tags folder, pointing to it
253 GIT_EXTERN(int) git_tag_create_f(
255 git_repository
*repo
,
256 const char *tag_name
,
257 const git_oid
*target
,
258 git_otype target_type
,
259 const git_signature
*tagger
,
260 const char *message
);
263 * Create a new tag in the repository from an existing
264 * `git_object` instance and overwrite an already existing
265 * tag reference, if any.
267 * This method replaces the `target` and `target_type`
268 * paremeters of `git_tag_create_f` by a single instance
269 * of a `const git_object *`, which is assured to be
270 * a proper object in the ODB and hence will create
273 * @see git_tag_create_f
275 GIT_EXTERN(int) git_tag_create_fo(
277 git_repository
*repo
,
278 const char *tag_name
,
279 const git_object
*target
,
280 const git_signature
*tagger
,
281 const char *message
);
284 * Delete an existing tag reference.
286 * @param repo Repository where lives the tag
288 * @param tag_name Name of the tag to be deleted;
289 * this name is validated for consistency.
291 * @return 0 on success; error code otherwise.
293 GIT_EXTERN(int) git_tag_delete(
294 git_repository
*repo
,
295 const char *tag_name
);
298 * Fill a list with all the tags in the Repository
300 * The string array will be filled with the names of the
301 * matching tags; these values are owned by the user and
302 * should be free'd manually when no longer needed, using
303 * `git_strarray_free`.
305 * @param array Pointer to a git_strarray structure where
306 * the tag names will be stored
307 * @param repo Repository where to find the tags
308 * @return 0 on success; error code otherwise
310 GIT_EXTERN(int) git_tag_list(
311 git_strarray
*tag_names
,
312 git_repository
*repo
);