Blame include/git2/describe.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_describe_h__
Packit Service 20376f
#define INCLUDE_git_describe_h__
Packit Service 20376f
Packit Service 20376f
#include "common.h"
Packit Service 20376f
#include "types.h"
Packit Service 20376f
#include "buffer.h"
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * @file git2/describe.h
Packit Service 20376f
 * @brief Git describing routines
Packit Service 20376f
 * @defgroup git_describe Git describing routines
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
 * Reference lookup strategy
Packit Service 20376f
 *
Packit Service 20376f
 * These behave like the --tags and --all optios to git-describe,
Packit Service 20376f
 * namely they say to look for any reference in either refs/tags/ or
Packit Service 20376f
 * refs/ respectively.
Packit Service 20376f
 */
Packit Service 20376f
typedef enum {
Packit Service 20376f
	GIT_DESCRIBE_DEFAULT,
Packit Service 20376f
	GIT_DESCRIBE_TAGS,
Packit Service 20376f
	GIT_DESCRIBE_ALL,
Packit Service 20376f
} git_describe_strategy_t;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Describe options structure
Packit Service 20376f
 *
Packit Service 20376f
 * Initialize with `GIT_DESCRIBE_OPTIONS_INIT` macro to correctly set
Packit Service 20376f
 * the `version` field.  E.g.
Packit Service 20376f
 *
Packit Service 20376f
 *		git_describe_options opts = GIT_DESCRIBE_OPTIONS_INIT;
Packit Service 20376f
 */
Packit Service 20376f
typedef struct git_describe_options {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
Packit Service 20376f
	unsigned int max_candidates_tags; /**< default: 10 */
Packit Service 20376f
	unsigned int describe_strategy; /**< default: GIT_DESCRIBE_DEFAULT */
Packit Service 20376f
	const char *pattern;
Packit Service 20376f
	/**
Packit Service 20376f
	 * When calculating the distance from the matching tag or
Packit Service 20376f
	 * reference, only walk down the first-parent ancestry.
Packit Service 20376f
	 */
Packit Service 20376f
	int only_follow_first_parent;
Packit Service 20376f
	/**
Packit Service 20376f
	 * If no matching tag or reference is found, the describe
Packit Service 20376f
	 * operation would normally fail. If this option is set, it
Packit Service 20376f
	 * will instead fall back to showing the full id of the
Packit Service 20376f
	 * commit.
Packit Service 20376f
	 */
Packit Service 20376f
	int show_commit_oid_as_fallback;
Packit Service 20376f
} git_describe_options;
Packit Service 20376f
Packit Service 20376f
#define GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS 10
Packit Service 20376f
#define GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE 7
Packit Service 20376f
Packit Service 20376f
#define GIT_DESCRIBE_OPTIONS_VERSION 1
Packit Service 20376f
#define GIT_DESCRIBE_OPTIONS_INIT { \
Packit Service 20376f
	GIT_DESCRIBE_OPTIONS_VERSION, \
Packit Service 20376f
	GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS, \
Packit Service 20376f
}
Packit Service 20376f
Packit Service 20376f
GIT_EXTERN(int) git_describe_init_options(git_describe_options *opts, unsigned int version);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Options for formatting the describe string
Packit Service 20376f
 */
Packit Service 20376f
typedef struct {
Packit Service 20376f
	unsigned int version;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Size of the abbreviated commit id to use. This value is the
Packit Service 20376f
	 * lower bound for the length of the abbreviated string. The
Packit Service 20376f
	 * default is 7.
Packit Service 20376f
	 */
Packit Service 20376f
	unsigned int abbreviated_size;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * Set to use the long format even when a shorter name could be used.
Packit Service 20376f
	 */
Packit Service 20376f
	int always_use_long_format;
Packit Service 20376f
Packit Service 20376f
	/**
Packit Service 20376f
	 * If the workdir is dirty and this is set, this string will
Packit Service 20376f
	 * be appended to the description string.
Packit Service 20376f
	 */
Packit Service 20376f
	const char *dirty_suffix;
Packit Service 20376f
} git_describe_format_options;
Packit Service 20376f
Packit Service 20376f
#define GIT_DESCRIBE_FORMAT_OPTIONS_VERSION 1
Packit Service 20376f
#define GIT_DESCRIBE_FORMAT_OPTIONS_INIT { \
Packit Service 20376f
		GIT_DESCRIBE_FORMAT_OPTIONS_VERSION,   \
Packit Service 20376f
		GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE, \
Packit Service 20376f
 }
Packit Service 20376f
Packit Service 20376f
GIT_EXTERN(int) git_describe_init_format_options(git_describe_format_options *opts, unsigned int version);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * A struct that stores the result of a describe operation.
Packit Service 20376f
 */
Packit Service 20376f
typedef struct git_describe_result git_describe_result;
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Describe a commit
Packit Service 20376f
 *
Packit Service 20376f
 * Perform the describe operation on the given committish object.
Packit Service 20376f
 *
Packit Service 20376f
 * @param result pointer to store the result. You must free this once
Packit Service 20376f
 * you're done with it.
Packit Service 20376f
 * @param committish a committish to describe
Packit Service 20376f
 * @param opts the lookup options
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_describe_commit(
Packit Service 20376f
	git_describe_result **result,
Packit Service 20376f
	git_object *committish,
Packit Service 20376f
	git_describe_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Describe a commit
Packit Service 20376f
 *
Packit Service 20376f
 * Perform the describe operation on the current commit and the
Packit Service 20376f
 * worktree. After peforming describe on HEAD, a status is run and the
Packit Service 20376f
 * description is considered to be dirty if there are.
Packit Service 20376f
 *
Packit Service 20376f
 * @param out pointer to store the result. You must free this once
Packit Service 20376f
 * you're done with it.
Packit Service 20376f
 * @param repo the repository in which to perform the describe
Packit Service 20376f
 * @param opts the lookup options
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_describe_workdir(
Packit Service 20376f
	git_describe_result **out,
Packit Service 20376f
	git_repository *repo,
Packit Service 20376f
	git_describe_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Print the describe result to a buffer
Packit Service 20376f
 *
Packit Service 20376f
 * @param out The buffer to store the result
Packit Service 20376f
 * @param result the result from `git_describe_commit()` or
Packit Service 20376f
 * `git_describe_workdir()`.
Packit Service 20376f
 * @param opts the formatting options
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(int) git_describe_format(
Packit Service 20376f
	git_buf *out,
Packit Service 20376f
	const git_describe_result *result,
Packit Service 20376f
	const git_describe_format_options *opts);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Free the describe result.
Packit Service 20376f
 */
Packit Service 20376f
GIT_EXTERN(void) git_describe_result_free(git_describe_result *result);
Packit Service 20376f
Packit Service 20376f
/** @} */
Packit Service 20376f
GIT_END_DECL
Packit Service 20376f
Packit Service 20376f
#endif