diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-30 07:19:14 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-09-30 07:24:28 +0200 |
commit | 3b6534b80768e8751b398cd3aeffb888e374c8d4 (patch) | |
tree | c373d53f835a8f868477cd03721a674123ec1b89 /include/git2/describe.h | |
parent | 1f501a086b4a9103f5ef5540c82c57d8559f0aff (diff) | |
download | libgit2-3b6534b80768e8751b398cd3aeffb888e374c8d4.tar.gz |
describe: split into gather and format steps
Instead of printing out to the buffer inside the information-gathering
phase, write the data to a intermediate result structure.
This allows us to split the options into gathering options and
formatting options, simplifying the gathering code.
Diffstat (limited to 'include/git2/describe.h')
-rw-r--r-- | include/git2/describe.h | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/include/git2/describe.h b/include/git2/describe.h index 0a845f6be..6007b004e 100644 --- a/include/git2/describe.h +++ b/include/git2/describe.h @@ -38,10 +38,8 @@ typedef struct git_describe_opts { unsigned int version; unsigned int max_candidates_tags; /** default: 10 */ - unsigned int abbreviated_size; unsigned int describe_strategy; /** default: GIT_DESCRIBE_DEFAULT */ const char *pattern; - int always_use_long_format; int only_follow_first_parent; int show_commit_oid_as_fallback; } git_describe_opts; @@ -53,13 +51,34 @@ typedef struct git_describe_opts { #define GIT_DESCRIBE_OPTIONS_INIT { \ GIT_DESCRIBE_OPTIONS_VERSION, \ GIT_DESCRIBE_DEFAULT_MAX_CANDIDATES_TAGS, \ - GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE} +} + +typedef struct { + unsigned int version; + + unsigned int abbreviated_size; + + int always_use_long_format; + char *dirty_suffix; +} git_describe_format_options; + +#define GIT_DESCRIBE_FORMAT_OPTIONS_VERSION 1 +#define GIT_DESCRIBE_FORMAT_OPTIONS_INIT { \ + GIT_DESCRIBE_FORMAT_OPTIONS_VERSION, \ + GIT_DESCRIBE_DEFAULT_ABBREVIATED_SIZE, \ + } + +typedef struct git_describe_result git_describe_result; GIT_EXTERN(int) git_describe_commit( - git_buf *out, + git_describe_result **result, git_object *committish, git_describe_opts *opts); +GIT_EXTERN(int) git_describe_format(git_buf *out, const git_describe_result *result, const git_describe_format_options *opts); + +GIT_EXTERN(void) git_describe_result_free(git_describe_result *result); + /** @} */ GIT_END_DECL |