Export parse_tag_buffer as git_tag__parse_buffer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/src/tag.c b/src/tag.c
index f87e4ff..6076eb6 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -61,7 +61,7 @@ const char *git_tag_message(git_tag *t)
return t->message;
}
-static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer_end)
+int git_tag__parse_buffer(git_tag *tag, const char *buffer, size_t length)
{
static const char *tag_types[] = {
NULL, "commit\n", "tree\n", "blob\n", "tag\n"
@@ -71,6 +71,8 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
char *search;
int error;
+ const char *buffer_end = buffer + length;
+
if ((error = git_oid__parse(&tag->target, &buffer, buffer_end, "object ")) < 0)
return git__rethrow(error, "Failed to parse tag. Object field invalid");
@@ -316,7 +318,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
return error;
/* validate the buffer */
- if ((error = parse_tag_buffer(&tag, buffer, buffer + strlen(buffer))) < GIT_SUCCESS)
+ if ((error = git_tag__parse_buffer(&tag, buffer, strlen(buffer))) < GIT_SUCCESS)
goto cleanup;
/* validate the target */
@@ -397,7 +399,7 @@ int git_tag_delete(git_repository *repo, const char *tag_name)
int git_tag__parse(git_tag *tag, git_odb_object *obj)
{
assert(tag);
- return parse_tag_buffer(tag, obj->raw.data, (char *)obj->raw.data + obj->raw.len);
+ return git_tag__parse_buffer(tag, obj->raw.data, obj->raw.len);
}
typedef struct {
diff --git a/src/tag.h b/src/tag.h
index c38350a..47f4255 100644
--- a/src/tag.h
+++ b/src/tag.h
@@ -24,5 +24,6 @@ struct git_tag {
void git_tag__free(git_tag *tag);
int git_tag__parse(git_tag *tag, git_odb_object *obj);
+int git_tag__parse_buffer(git_tag *tag, const char *data, size_t len);
#endif