Commit b60deb02 by Jay Freeman (saurik)

Export parse_tag_buffer as git_tag__parse_buffer.

parent 9c94a356
...@@ -61,7 +61,7 @@ const char *git_tag_message(git_tag *t) ...@@ -61,7 +61,7 @@ const char *git_tag_message(git_tag *t)
return t->message; 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[] = { static const char *tag_types[] = {
NULL, "commit\n", "tree\n", "blob\n", "tag\n" 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 ...@@ -71,6 +71,8 @@ static int parse_tag_buffer(git_tag *tag, const char *buffer, const char *buffer
char *search; char *search;
int error; int error;
const char *buffer_end = buffer + length;
if ((error = git_oid__parse(&tag->target, &buffer, buffer_end, "object ")) < 0) if ((error = git_oid__parse(&tag->target, &buffer, buffer_end, "object ")) < 0)
return git__rethrow(error, "Failed to parse tag. Object field invalid"); 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 ...@@ -316,7 +318,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
return error; return error;
/* validate the buffer */ /* 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; goto cleanup;
/* validate the target */ /* validate the target */
...@@ -397,7 +399,7 @@ int git_tag_delete(git_repository *repo, const char *tag_name) ...@@ -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) int git_tag__parse(git_tag *tag, git_odb_object *obj)
{ {
assert(tag); 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 { typedef struct {
......
...@@ -24,5 +24,6 @@ struct git_tag { ...@@ -24,5 +24,6 @@ struct git_tag {
void git_tag__free(git_tag *tag); void git_tag__free(git_tag *tag);
int git_tag__parse(git_tag *tag, git_odb_object *obj); 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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment