Blame include/git2/tag.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_git_tag_h__
Packit Service 20376f
#define INCLUDE_git_tag_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include "types.h"
Packit Service 20376f
#include "oid.h"
Packit Service 20376f
#include "object.h"
Packit Service 20376f
#include "strarray.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/tag.h
Packit Service 20376f
 * @brief Git tag parsing routines
Packit Service 20376f
 * @defgroup git_tag Git tag management
Packit Service 20376f
 * @ingroup Git
Packit Service 20376f
 * @{
Packit Service 20376f
 */
Packit Service 20376f
GIT_BEGIN_DECL
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Lookup a tag object from the repository.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to the looked up tag
Packit Service 20376f
 * @param repo the repo to use when locating the tag.
Packit Service 20376f
 * @param id identity of the tag to locate.
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_lookup(
Packit Service 20376f
	git_tag **out, git_repository *repo, const git_oid *id);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Lookup a tag object from the repository,
Packit Service 20376f
 * given a prefix of its identifier (short id).
Packit Service 20376f
 *
Packit Service 20376f
 * @see git_object_lookup_prefix
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to the looked up tag
Packit Service 20376f
 * @param repo the repo to use when locating the tag.
Packit Service 20376f
 * @param id identity of the tag to locate.
Packit Service 20376f
 * @param len the length of the short identifier
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_lookup_prefix(
Packit Service 20376f
	git_tag **out, git_repository *repo, const git_oid *id, size_t len);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Close an open tag
Packit Service 20376f
 *
Packit Service 20376f
 * You can no longer use the git_tag pointer after this call.
Packit Service 20376f
 *
Packit Service 20376f
 * IMPORTANT: You MUST call this method when you are through with a tag to
Packit Service 20376f
 * release memory. Failure to do so will cause a memory leak.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag the tag to close
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_tag_free(git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the id of a tag.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return object identity for the tag.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_oid *) git_tag_id(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the repository that contains the tag.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag A previously loaded tag.
Packit Service 20376f
 * @return Repository that contains this tag.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(git_repository *) git_tag_owner(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the tagged object of a tag
Packit Service 20376f
 *
Packit Service 20376f
 * This method performs a repository lookup for the
Packit Service 20376f
 * given object and returns it
Packit Service 20376f
 *
Packit Service 20376f
 * @param target_out pointer where to store the target
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_target(git_object **target_out, const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the OID of the tagged object of a tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return pointer to the OID
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_oid *) git_tag_target_id(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the type of a tag's tagged object
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return type of the tagged object
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(git_otype) git_tag_target_type(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the name of a tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return name of the tag
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const char *) git_tag_name(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the tagger (author) of a tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return reference to the tag's author or NULL when unspecified
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const git_signature *) git_tag_tagger(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Get the message of a tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag a previously loaded tag.
Packit Service 20376f
 * @return message of the tag or NULL when unspecified
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(const char *) git_tag_message(const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new tag in the repository from an object
Packit Service 20376f
 *
Packit Service 20376f
 * A new reference will also be created pointing to
Packit Service 20376f
 * this tag object. If `force` is true and a reference
Packit Service 20376f
 * already exists with the given name, it'll be replaced.
Packit Service 20376f
 *
Packit Service 20376f
 * The message will not be cleaned up. This can be achieved
Packit Service 20376f
 * through `git_message_prettify()`.
Packit Service 20376f
 *
Packit Service 20376f
 * The tag name will be checked for validity. You must avoid
Packit Service 20376f
 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
Packit Service 20376f
 * sequences ".." and "@{" which have special meaning to revparse.
Packit Service 20376f
 *
Packit Service 20376f
 * @param oid Pointer where to store the OID of the
Packit Service 20376f
 * newly created tag. If the tag already exists, this parameter
Packit Service 20376f
 * will be the oid of the existing tag, and the function will
Packit Service 20376f
 * return a GIT_EEXISTS error code.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository where to store the tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_name Name for the tag; this name is validated
Packit Service 20376f
 * for consistency. It should also not conflict with an
Packit Service 20376f
 * already existing tag name
Packit Service 20376f
 *
Packit Service 20376f
 * @param target Object to which this tag points. This object
Packit Service 20376f
 * must belong to the given `repo`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tagger Signature of the tagger for this tag, and
Packit Service 20376f
 * of the tagging time
Packit Service 20376f
 *
Packit Service 20376f
 * @param message Full message for this tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param force Overwrite existing references
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success, GIT_EINVALIDSPEC or an error code
Packit Service 20376f
 *	A tag object is written to the ODB, and a proper reference
Packit Service 20376f
 *	is written in the /refs/tags folder, pointing to it
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_create(
Packit Service 20376f
	git_oid *oid,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const char *tag_name,
Packit Service 20376f
	const git_object *target,
Packit Service 20376f
	const git_signature *tagger,
Packit Service 20376f
	const char *message,
Packit Service 20376f
	int force);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new tag in the object database pointing to a git_object
Packit Service 20376f
 *
Packit Service 20376f
 * The message will not be cleaned up. This can be achieved
Packit Service 20376f
 * through `git_message_prettify()`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param oid Pointer where to store the OID of the
Packit Service 20376f
 * newly created tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository where to store the tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_name Name for the tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param target Object to which this tag points. This object
Packit Service 20376f
 * must belong to the given `repo`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tagger Signature of the tagger for this tag, and
Packit Service 20376f
 * of the tagging time
Packit Service 20376f
 *
Packit Service 20376f
 * @param message Full message for this tag
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_annotation_create(
Packit Service 20376f
	git_oid *oid,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const char *tag_name,
Packit Service 20376f
	const git_object *target,
Packit Service 20376f
	const git_signature *tagger,
Packit Service 20376f
	const char *message);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new tag in the repository from a buffer
Packit Service 20376f
 *
Packit Service 20376f
 * @param oid Pointer where to store the OID of the newly created tag
Packit Service 20376f
 * @param repo Repository where to store the tag
Packit Service 20376f
 * @param buffer Raw tag data
Packit Service 20376f
 * @param force Overwrite existing tags
Packit Service 20376f
 * @return 0 on success; error code otherwise
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_create_frombuffer(
Packit Service 20376f
	git_oid *oid,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const char *buffer,
Packit Service 20376f
	int force);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create a new lightweight tag pointing at a target object
Packit Service 20376f
 *
Packit Service 20376f
 * A new direct reference will be created pointing to
Packit Service 20376f
 * this target object. If `force` is true and a reference
Packit Service 20376f
 * already exists with the given name, it'll be replaced.
Packit Service 20376f
 *
Packit Service 20376f
 * The tag name will be checked for validity.
Packit Service 20376f
 * See `git_tag_create()` for rules about valid names.
Packit Service 20376f
 *
Packit Service 20376f
 * @param oid Pointer where to store the OID of the provided
Packit Service 20376f
 * target object. If the tag already exists, this parameter
Packit Service 20376f
 * will be filled with the oid of the existing pointed object
Packit Service 20376f
 * and the function will return a GIT_EEXISTS error code.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository where to store the lightweight tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_name Name for the tag; this name is validated
Packit Service 20376f
 * for consistency. It should also not conflict with an
Packit Service 20376f
 * already existing tag name
Packit Service 20376f
 *
Packit Service 20376f
 * @param target Object to which this tag points. This object
Packit Service 20376f
 * must belong to the given `repo`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param force Overwrite existing references
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success, GIT_EINVALIDSPEC or an error code
Packit Service 20376f
 *	A proper reference is written in the /refs/tags folder,
Packit Service 20376f
 * pointing to the provided target object
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_create_lightweight(
Packit Service 20376f
	git_oid *oid,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const char *tag_name,
Packit Service 20376f
	const git_object *target,
Packit Service 20376f
	int force);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Delete an existing tag reference.
Packit Service 20376f
 *
Packit Service 20376f
 * The tag name will be checked for validity.
Packit Service 20376f
 * See `git_tag_create()` for rules about valid names.
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository where lives the tag
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_name Name of the tag to be deleted;
Packit Service 20376f
 * this name is validated for consistency.
Packit Service 20376f
 *
Packit Service 20376f
 * @return 0 on success, GIT_EINVALIDSPEC or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_delete(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	const char *tag_name);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Fill a list with all the tags in the Repository
Packit Service 20376f
 *
Packit Service 20376f
 * The string array will be filled with the names of the
Packit Service 20376f
 * matching tags; these values are owned by the user and
Packit Service 20376f
 * should be free'd manually when no longer needed, using
Packit Service 20376f
 * `git_strarray_free`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_names Pointer to a git_strarray structure where
Packit Service 20376f
 *		the tag names will be stored
Packit Service 20376f
 * @param repo Repository where to find the tags
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_list(
Packit Service 20376f
	git_strarray *tag_names,
Packit Service 20376f
	git_repository *repo);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Fill a list with all the tags in the Repository
Packit Service 20376f
 * which name match a defined pattern
Packit Service 20376f
 *
Packit Service 20376f
 * If an empty pattern is provided, all the tags
Packit Service 20376f
 * will be returned.
Packit Service 20376f
 *
Packit Service 20376f
 * The string array will be filled with the names of the
Packit Service 20376f
 * matching tags; these values are owned by the user and
Packit Service 20376f
 * should be free'd manually when no longer needed, using
Packit Service 20376f
 * `git_strarray_free`.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_names Pointer to a git_strarray structure where
Packit Service 20376f
 *		the tag names will be stored
Packit Service 20376f
 * @param pattern Standard fnmatch pattern
Packit Service 20376f
 * @param repo Repository where to find the tags
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_list_match(
Packit Service 20376f
	git_strarray *tag_names,
Packit Service 20376f
	const char *pattern,
Packit Service 20376f
	git_repository *repo);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
typedef int (*git_tag_foreach_cb)(const char *name, git_oid *oid, void *payload);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Call callback `cb' for each tag in the repository
Packit Service 20376f
 *
Packit Service 20376f
 * @param repo Repository
Packit Service 20376f
 * @param callback Callback function
Packit Service 20376f
 * @param payload Pointer to callback data (optional)
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_foreach(
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_tag_foreach_cb callback,
Packit Service 20376f
	void *payload);
Packit Service 20376f
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Recursively peel a tag until a non tag git_object is found
Packit Service 20376f
 *
Packit Service 20376f
 * The retrieved `tag_target` object is owned by the repository
Packit Service 20376f
 * and should be closed with the `git_object_free` method.
Packit Service 20376f
 *
Packit Service 20376f
 * @param tag_target_out Pointer to the peeled git_object
Packit Service 20376f
 * @param tag The tag to be processed
Packit Service 20376f
 * @return 0 or an error code
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_peel(
Packit Service 20376f
	git_object **tag_target_out,
Packit Service 20376f
	const git_tag *tag);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Create an in-memory copy of a tag. The copy must be explicitly
Packit Service 20376f
 * free'd or it will leak.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out Pointer to store the copy of the tag
Packit Service 20376f
 * @param source Original tag to copy
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_tag_dup(git_tag **out, git_tag *source);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
#endif