Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:39

0001 /*
0002  * Copyright (C) the libgit2 contributors. All rights reserved.
0003  *
0004  * This file is part of libgit2, distributed under the GNU GPL v2 with
0005  * a Linking Exception. For full terms see the included COPYING file.
0006  */
0007 #ifndef INCLUDE_git_tag_h__
0008 #define INCLUDE_git_tag_h__
0009 
0010 #include "common.h"
0011 #include "types.h"
0012 #include "oid.h"
0013 #include "object.h"
0014 #include "strarray.h"
0015 
0016 /**
0017  * @file git2/tag.h
0018  * @brief Git tag parsing routines
0019  * @defgroup git_tag Git tag management
0020  * @ingroup Git
0021  * @{
0022  */
0023 GIT_BEGIN_DECL
0024 
0025 /**
0026  * Lookup a tag object from the repository.
0027  *
0028  * @param out pointer to the looked up tag
0029  * @param repo the repo to use when locating the tag.
0030  * @param id identity of the tag to locate.
0031  * @return 0 or an error code
0032  */
0033 GIT_EXTERN(int) git_tag_lookup(
0034     git_tag **out, git_repository *repo, const git_oid *id);
0035 
0036 /**
0037  * Lookup a tag object from the repository,
0038  * given a prefix of its identifier (short id).
0039  *
0040  * @see git_object_lookup_prefix
0041  *
0042  * @param out pointer to the looked up tag
0043  * @param repo the repo to use when locating the tag.
0044  * @param id identity of the tag to locate.
0045  * @param len the length of the short identifier
0046  * @return 0 or an error code
0047  */
0048 GIT_EXTERN(int) git_tag_lookup_prefix(
0049     git_tag **out, git_repository *repo, const git_oid *id, size_t len);
0050 
0051 /**
0052  * Close an open tag
0053  *
0054  * You can no longer use the git_tag pointer after this call.
0055  *
0056  * IMPORTANT: You MUST call this method when you are through with a tag to
0057  * release memory. Failure to do so will cause a memory leak.
0058  *
0059  * @param tag the tag to close
0060  */
0061 GIT_EXTERN(void) git_tag_free(git_tag *tag);
0062 
0063 /**
0064  * Get the id of a tag.
0065  *
0066  * @param tag a previously loaded tag.
0067  * @return object identity for the tag.
0068  */
0069 GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag);
0070 
0071 /**
0072  * Get the repository that contains the tag.
0073  *
0074  * @param tag A previously loaded tag.
0075  * @return Repository that contains this tag.
0076  */
0077 GIT_EXTERN(git_repository *) git_tag_owner(const git_tag *tag);
0078 
0079 /**
0080  * Get the tagged object of a tag
0081  *
0082  * This method performs a repository lookup for the
0083  * given object and returns it
0084  *
0085  * @param target_out pointer where to store the target
0086  * @param tag a previously loaded tag.
0087  * @return 0 or an error code
0088  */
0089 GIT_EXTERN(int) git_tag_target(git_object **target_out, const git_tag *tag);
0090 
0091 /**
0092  * Get the OID of the tagged object of a tag
0093  *
0094  * @param tag a previously loaded tag.
0095  * @return pointer to the OID
0096  */
0097 GIT_EXTERN(const git_oid *) git_tag_target_id(const git_tag *tag);
0098 
0099 /**
0100  * Get the type of a tag's tagged object
0101  *
0102  * @param tag a previously loaded tag.
0103  * @return type of the tagged object
0104  */
0105 GIT_EXTERN(git_object_t) git_tag_target_type(const git_tag *tag);
0106 
0107 /**
0108  * Get the name of a tag
0109  *
0110  * @param tag a previously loaded tag.
0111  * @return name of the tag
0112  */
0113 GIT_EXTERN(const char *) git_tag_name(const git_tag *tag);
0114 
0115 /**
0116  * Get the tagger (author) of a tag
0117  *
0118  * @param tag a previously loaded tag.
0119  * @return reference to the tag's author or NULL when unspecified
0120  */
0121 GIT_EXTERN(const git_signature *) git_tag_tagger(const git_tag *tag);
0122 
0123 /**
0124  * Get the message of a tag
0125  *
0126  * @param tag a previously loaded tag.
0127  * @return message of the tag or NULL when unspecified
0128  */
0129 GIT_EXTERN(const char *) git_tag_message(const git_tag *tag);
0130 
0131 
0132 /**
0133  * Create a new tag in the repository from an object
0134  *
0135  * A new reference will also be created pointing to
0136  * this tag object. If `force` is true and a reference
0137  * already exists with the given name, it'll be replaced.
0138  *
0139  * The message will not be cleaned up. This can be achieved
0140  * through `git_message_prettify()`.
0141  *
0142  * The tag name will be checked for validity. You must avoid
0143  * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
0144  * sequences ".." and "@{" which have special meaning to revparse.
0145  *
0146  * @param oid Pointer where to store the OID of the
0147  * newly created tag. If the tag already exists, this parameter
0148  * will be the oid of the existing tag, and the function will
0149  * return a GIT_EEXISTS error code.
0150  *
0151  * @param repo Repository where to store the tag
0152  *
0153  * @param tag_name Name for the tag; this name is validated
0154  * for consistency. It should also not conflict with an
0155  * already existing tag name
0156  *
0157  * @param target Object to which this tag points. This object
0158  * must belong to the given `repo`.
0159  *
0160  * @param tagger Signature of the tagger for this tag, and
0161  * of the tagging time
0162  *
0163  * @param message Full message for this tag
0164  *
0165  * @param force Overwrite existing references
0166  *
0167  * @return 0 on success, GIT_EINVALIDSPEC or an error code
0168  *  A tag object is written to the ODB, and a proper reference
0169  *  is written in the /refs/tags folder, pointing to it
0170  */
0171 GIT_EXTERN(int) git_tag_create(
0172     git_oid *oid,
0173     git_repository *repo,
0174     const char *tag_name,
0175     const git_object *target,
0176     const git_signature *tagger,
0177     const char *message,
0178     int force);
0179 
0180 /**
0181  * Create a new tag in the object database pointing to a git_object
0182  *
0183  * The message will not be cleaned up. This can be achieved
0184  * through `git_message_prettify()`.
0185  *
0186  * @param oid Pointer where to store the OID of the
0187  * newly created tag
0188  *
0189  * @param repo Repository where to store the tag
0190  *
0191  * @param tag_name Name for the tag
0192  *
0193  * @param target Object to which this tag points. This object
0194  * must belong to the given `repo`.
0195  *
0196  * @param tagger Signature of the tagger for this tag, and
0197  * of the tagging time
0198  *
0199  * @param message Full message for this tag
0200  *
0201  * @return 0 on success or an error code
0202  */
0203 GIT_EXTERN(int) git_tag_annotation_create(
0204     git_oid *oid,
0205     git_repository *repo,
0206     const char *tag_name,
0207     const git_object *target,
0208     const git_signature *tagger,
0209     const char *message);
0210 
0211 /**
0212  * Create a new tag in the repository from a buffer
0213  *
0214  * @param oid Pointer where to store the OID of the newly created tag
0215  * @param repo Repository where to store the tag
0216  * @param buffer Raw tag data
0217  * @param force Overwrite existing tags
0218  * @return 0 on success; error code otherwise
0219  */
0220 GIT_EXTERN(int) git_tag_create_from_buffer(
0221     git_oid *oid,
0222     git_repository *repo,
0223     const char *buffer,
0224     int force);
0225 
0226 /**
0227  * Create a new lightweight tag pointing at a target object
0228  *
0229  * A new direct reference will be created pointing to
0230  * this target object. If `force` is true and a reference
0231  * already exists with the given name, it'll be replaced.
0232  *
0233  * The tag name will be checked for validity.
0234  * See `git_tag_create()` for rules about valid names.
0235  *
0236  * @param oid Pointer where to store the OID of the provided
0237  * target object. If the tag already exists, this parameter
0238  * will be filled with the oid of the existing pointed object
0239  * and the function will return a GIT_EEXISTS error code.
0240  *
0241  * @param repo Repository where to store the lightweight tag
0242  *
0243  * @param tag_name Name for the tag; this name is validated
0244  * for consistency. It should also not conflict with an
0245  * already existing tag name
0246  *
0247  * @param target Object to which this tag points. This object
0248  * must belong to the given `repo`.
0249  *
0250  * @param force Overwrite existing references
0251  *
0252  * @return 0 on success, GIT_EINVALIDSPEC or an error code
0253  *  A proper reference is written in the /refs/tags folder,
0254  * pointing to the provided target object
0255  */
0256 GIT_EXTERN(int) git_tag_create_lightweight(
0257     git_oid *oid,
0258     git_repository *repo,
0259     const char *tag_name,
0260     const git_object *target,
0261     int force);
0262 
0263 /**
0264  * Delete an existing tag reference.
0265  *
0266  * The tag name will be checked for validity.
0267  * See `git_tag_create()` for rules about valid names.
0268  *
0269  * @param repo Repository where lives the tag
0270  *
0271  * @param tag_name Name of the tag to be deleted;
0272  * this name is validated for consistency.
0273  *
0274  * @return 0 on success, GIT_EINVALIDSPEC or an error code
0275  */
0276 GIT_EXTERN(int) git_tag_delete(
0277     git_repository *repo,
0278     const char *tag_name);
0279 
0280 /**
0281  * Fill a list with all the tags in the Repository
0282  *
0283  * The string array will be filled with the names of the
0284  * matching tags; these values are owned by the user and
0285  * should be free'd manually when no longer needed, using
0286  * `git_strarray_free`.
0287  *
0288  * @param tag_names Pointer to a git_strarray structure where
0289  *      the tag names will be stored
0290  * @param repo Repository where to find the tags
0291  * @return 0 or an error code
0292  */
0293 GIT_EXTERN(int) git_tag_list(
0294     git_strarray *tag_names,
0295     git_repository *repo);
0296 
0297 /**
0298  * Fill a list with all the tags in the Repository
0299  * which name match a defined pattern
0300  *
0301  * If an empty pattern is provided, all the tags
0302  * will be returned.
0303  *
0304  * The string array will be filled with the names of the
0305  * matching tags; these values are owned by the user and
0306  * should be free'd manually when no longer needed, using
0307  * `git_strarray_free`.
0308  *
0309  * @param tag_names Pointer to a git_strarray structure where
0310  *      the tag names will be stored
0311  * @param pattern Standard fnmatch pattern
0312  * @param repo Repository where to find the tags
0313  * @return 0 or an error code
0314  */
0315 GIT_EXTERN(int) git_tag_list_match(
0316     git_strarray *tag_names,
0317     const char *pattern,
0318     git_repository *repo);
0319 
0320 /**
0321  * Callback used to iterate over tag names
0322  *
0323  * @see git_tag_foreach
0324  *
0325  * @param name The tag name
0326  * @param oid The tag's OID
0327  * @param payload Payload passed to git_tag_foreach
0328  * @return non-zero to terminate the iteration
0329  */
0330 typedef int GIT_CALLBACK(git_tag_foreach_cb)(const char *name, git_oid *oid, void *payload);
0331 
0332 /**
0333  * Call callback `cb' for each tag in the repository
0334  *
0335  * @param repo Repository
0336  * @param callback Callback function
0337  * @param payload Pointer to callback data (optional)
0338  */
0339 GIT_EXTERN(int) git_tag_foreach(
0340     git_repository *repo,
0341     git_tag_foreach_cb callback,
0342     void *payload);
0343 
0344 
0345 /**
0346  * Recursively peel a tag until a non tag git_object is found
0347  *
0348  * The retrieved `tag_target` object is owned by the repository
0349  * and should be closed with the `git_object_free` method.
0350  *
0351  * @param tag_target_out Pointer to the peeled git_object
0352  * @param tag The tag to be processed
0353  * @return 0 or an error code
0354  */
0355 GIT_EXTERN(int) git_tag_peel(
0356     git_object **tag_target_out,
0357     const git_tag *tag);
0358 
0359 /**
0360  * Create an in-memory copy of a tag. The copy must be explicitly
0361  * free'd or it will leak.
0362  *
0363  * @param out Pointer to store the copy of the tag
0364  * @param source Original tag to copy
0365  * @return 0
0366  */
0367 GIT_EXTERN(int) git_tag_dup(git_tag **out, git_tag *source);
0368 
0369 /**
0370  * Determine whether a tag name is valid, meaning that (when prefixed
0371  * with `refs/tags/`) that it is a valid reference name, and that any
0372  * additional tag name restrictions are imposed (eg, it cannot start
0373  * with a `-`).
0374  *
0375  * @param valid output pointer to set with validity of given tag name
0376  * @param name a tag name to test
0377  * @return 0 on success or an error code
0378  */
0379 GIT_EXTERN(int) git_tag_name_is_valid(int *valid, const char *name);
0380 
0381 /** @} */
0382 GIT_END_DECL
0383 #endif