|
||||
File indexing completed on 2025-01-18 09:59:37
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_describe_h__ 0008 #define INCLUDE_git_describe_h__ 0009 0010 #include "common.h" 0011 #include "types.h" 0012 #include "buffer.h" 0013 0014 /** 0015 * @file git2/describe.h 0016 * @brief Git describing routines 0017 * @defgroup git_describe Git describing routines 0018 * @ingroup Git 0019 * @{ 0020 */ 0021 GIT_BEGIN_DECL 0022 0023 /** 0024 * Reference lookup strategy 0025 * 0026 * These behave like the --tags and --all options to git-describe, 0027 * namely they say to look for any reference in either refs/tags/ or 0028 * refs/ respectively. 0029 */ 0030 typedef enum { 0031 GIT_DESCRIBE_DEFAULT, 0032 GIT_DESCRIBE_TAGS, 0033 GIT_DESCRIBE_ALL 0034 } git_describe_strategy_t; 0035 0036 /** 0037 * Describe options structure 0038 * 0039 * Initialize with `GIT_DESCRIBE_OPTIONS_INIT`. Alternatively, you can 0040 * use `git_describe_options_init`. 0041 * 0042 */ 0043 typedef struct git_describe_options { 0044 unsigned int version; 0045 0046 unsigned int max_candidates_tags; /**< default: 10 */ 0047 unsigned int describe_strategy; /**< default: GIT_DESCRIBE_DEFAULT */ 0048 const char *pattern; 0049 /** 0050 * When calculating the distance from the matching tag or 0051 * reference, only walk down the first-parent ancestry. 0052 */ 0053 int only_follow_first_parent; 0054 /** 0055 * If no matching tag or reference is found, the describe 0056 * operation would normally fail. If this option is set, it 0057 * will instead fall back to showing the full id of the 0058 * commit. 0059 */ 0060 int show_commit_oid_as_fallback; 0061 } git_describe_options; 0062 0063 #define GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS 10 0064 #define GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE 7 0065 0066 #define GIT_DESCRIBE_OPTIONS_VERSION 1 0067 #define GIT_DESCRIBE_OPTIONS_INIT { \ 0068 GIT_DESCRIBE_OPTIONS_VERSION, \ 0069 GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS, \ 0070 } 0071 0072 /** 0073 * Initialize git_describe_options structure 0074 * 0075 * Initializes a `git_describe_options` with default values. Equivalent to creating 0076 * an instance with GIT_DESCRIBE_OPTIONS_INIT. 0077 * 0078 * @param opts The `git_describe_options` struct to initialize. 0079 * @param version The struct version; pass `GIT_DESCRIBE_OPTIONS_VERSION`. 0080 * @return Zero on success; -1 on failure. 0081 */ 0082 GIT_EXTERN(int) git_describe_options_init(git_describe_options *opts, unsigned int version); 0083 0084 /** 0085 * Describe format options structure 0086 * 0087 * Initialize with `GIT_DESCRIBE_FORMAT_OPTIONS_INIT`. Alternatively, you can 0088 * use `git_describe_format_options_init`. 0089 * 0090 */ 0091 typedef struct { 0092 unsigned int version; 0093 0094 /** 0095 * Size of the abbreviated commit id to use. This value is the 0096 * lower bound for the length of the abbreviated string. The 0097 * default is 7. 0098 */ 0099 unsigned int abbreviated_size; 0100 0101 /** 0102 * Set to use the long format even when a shorter name could be used. 0103 */ 0104 int always_use_long_format; 0105 0106 /** 0107 * If the workdir is dirty and this is set, this string will 0108 * be appended to the description string. 0109 */ 0110 const char *dirty_suffix; 0111 } git_describe_format_options; 0112 0113 #define GIT_DESCRIBE_FORMAT_OPTIONS_VERSION 1 0114 #define GIT_DESCRIBE_FORMAT_OPTIONS_INIT { \ 0115 GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, \ 0116 GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE, \ 0117 } 0118 0119 /** 0120 * Initialize git_describe_format_options structure 0121 * 0122 * Initializes a `git_describe_format_options` with default values. Equivalent to creating 0123 * an instance with GIT_DESCRIBE_FORMAT_OPTIONS_INIT. 0124 * 0125 * @param opts The `git_describe_format_options` struct to initialize. 0126 * @param version The struct version; pass `GIT_DESCRIBE_FORMAT_OPTIONS_VERSION`. 0127 * @return Zero on success; -1 on failure. 0128 */ 0129 GIT_EXTERN(int) git_describe_format_options_init(git_describe_format_options *opts, unsigned int version); 0130 0131 /** 0132 * A struct that stores the result of a describe operation. 0133 */ 0134 typedef struct git_describe_result git_describe_result; 0135 0136 /** 0137 * Describe a commit 0138 * 0139 * Perform the describe operation on the given committish object. 0140 * 0141 * @param result pointer to store the result. You must free this once 0142 * you're done with it. 0143 * @param committish a committish to describe 0144 * @param opts the lookup options (or NULL for defaults) 0145 * @return 0 or an error code. 0146 */ 0147 GIT_EXTERN(int) git_describe_commit( 0148 git_describe_result **result, 0149 git_object *committish, 0150 git_describe_options *opts); 0151 0152 /** 0153 * Describe a commit 0154 * 0155 * Perform the describe operation on the current commit and the 0156 * worktree. After performing describe on HEAD, a status is run and the 0157 * description is considered to be dirty if there are. 0158 * 0159 * @param out pointer to store the result. You must free this once 0160 * you're done with it. 0161 * @param repo the repository in which to perform the describe 0162 * @param opts the lookup options (or NULL for defaults) 0163 * @return 0 or an error code. 0164 */ 0165 GIT_EXTERN(int) git_describe_workdir( 0166 git_describe_result **out, 0167 git_repository *repo, 0168 git_describe_options *opts); 0169 0170 /** 0171 * Print the describe result to a buffer 0172 * 0173 * @param out The buffer to store the result 0174 * @param result the result from `git_describe_commit()` or 0175 * `git_describe_workdir()`. 0176 * @param opts the formatting options (or NULL for defaults) 0177 * @return 0 or an error code. 0178 */ 0179 GIT_EXTERN(int) git_describe_format( 0180 git_buf *out, 0181 const git_describe_result *result, 0182 const git_describe_format_options *opts); 0183 0184 /** 0185 * Free the describe result. 0186 * 0187 * @param result The result to free. 0188 */ 0189 GIT_EXTERN(void) git_describe_result_free(git_describe_result *result); 0190 0191 /** @} */ 0192 GIT_END_DECL 0193 0194 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |