diff options
author | Russell Belfer <rb@github.com> | 2013-04-16 22:51:02 +0400 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-04-22 18:52:06 +0400 |
commit | 3f27127d15dfe69943d3c9ddf96d09a2300de3a9 (patch) | |
tree | 77970a2d28265f4d4319f6613aff4a6501d57c12 /src/tag.c | |
parent | 786062639f05e361da977f3f1f6286141fa12fca (diff) |
Simplify object table parse functions
This unifies the object parse functions into one signature that
takes an odb_object.
Diffstat (limited to 'src/tag.c')
-rw-r--r-- | src/tag.c | 38 |
1 files changed, 23 insertions, 15 deletions
@@ -70,13 +70,12 @@ static int tag_error(const char *str) return -1; } -int git_tag__parse(void *_tag, const char *buffer, const char *buffer_end) +static int tag_parse(git_tag *tag, const char *buffer, const char *buffer_end) { static const char *tag_types[] = { NULL, "commit\n", "tree\n", "blob\n", "tag\n" }; - git_tag *tag = _tag; unsigned int i; size_t text_len; char *search; @@ -157,6 +156,15 @@ int git_tag__parse(void *_tag, const char *buffer, const char *buffer_end) return 0; } +int git_tag__parse(void *_tag, git_odb_object *odb_obj) +{ + git_tag *tag = _tag; + const char *buffer = git_odb_object_data(odb_obj); + const char *buffer_end = buffer + git_odb_object_size(odb_obj); + + return tag_parse(tag, buffer, buffer_end); +} + static int retrieve_tag_reference( git_reference **tag_reference_out, git_buf *ref_name_out, @@ -277,23 +285,23 @@ cleanup: } int git_tag_create( - git_oid *oid, - git_repository *repo, - const char *tag_name, - const git_object *target, - const git_signature *tagger, - const char *message, - int allow_ref_overwrite) + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + const git_signature *tagger, + const char *message, + int allow_ref_overwrite) { return git_tag_create__internal(oid, repo, tag_name, target, tagger, message, allow_ref_overwrite, 1); } int git_tag_create_lightweight( - git_oid *oid, - git_repository *repo, - const char *tag_name, - const git_object *target, - int allow_ref_overwrite) + git_oid *oid, + git_repository *repo, + const char *tag_name, + const git_object *target, + int allow_ref_overwrite) { return git_tag_create__internal(oid, repo, tag_name, target, NULL, NULL, allow_ref_overwrite, 0); } @@ -317,7 +325,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu return -1; /* validate the buffer */ - if (git_tag__parse(&tag, buffer, buffer + strlen(buffer)) < 0) + if (tag_parse(&tag, buffer, buffer + strlen(buffer)) < 0) return -1; /* validate the target */ |