diff options
Diffstat (limited to 'src/tag.c')
-rw-r--r-- | src/tag.c | 47 |
1 files changed, 23 insertions, 24 deletions
@@ -9,7 +9,6 @@ #include "commit.h" #include "signature.h" -#include "message.h" #include "wildmatch.h" #include "git2/object.h" #include "git2/repository.h" @@ -176,7 +175,7 @@ int git_tag__parse(void *_tag, git_odb_object *odb_obj) static int retrieve_tag_reference( git_reference **tag_reference_out, - git_buf *ref_name_out, + git_str *ref_name_out, git_repository *repo, const char *tag_name) { @@ -185,7 +184,7 @@ static int retrieve_tag_reference( *tag_reference_out = NULL; - if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) + if (git_str_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) return -1; error = git_reference_lookup(&tag_ref, repo, ref_name_out->ptr); @@ -199,11 +198,11 @@ static int retrieve_tag_reference( static int retrieve_tag_reference_oid( git_oid *oid, - git_buf *ref_name_out, + git_str *ref_name_out, git_repository *repo, const char *tag_name) { - if (git_buf_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) + if (git_str_joinpath(ref_name_out, GIT_REFS_TAGS_DIR, tag_name) < 0) return -1; return git_reference_name_to_id(oid, repo, ref_name_out->ptr); @@ -217,16 +216,16 @@ static int write_tag_annotation( const git_signature *tagger, const char *message) { - git_buf tag = GIT_BUF_INIT; + git_str tag = GIT_STR_INIT; git_odb *odb; git_oid__writebuf(&tag, "object ", git_object_id(target)); - git_buf_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target))); - git_buf_printf(&tag, "tag %s\n", tag_name); + git_str_printf(&tag, "type %s\n", git_object_type2string(git_object_type(target))); + git_str_printf(&tag, "tag %s\n", tag_name); git_signature__writebuf(&tag, "tagger ", tagger); - git_buf_putc(&tag, '\n'); + git_str_putc(&tag, '\n'); - if (git_buf_puts(&tag, message) < 0) + if (git_str_puts(&tag, message) < 0) goto on_error; if (git_repository_odb__weakptr(&odb, repo) < 0) @@ -235,11 +234,11 @@ static int write_tag_annotation( if (git_odb_write(oid, odb, tag.ptr, tag.size, GIT_OBJECT_TAG) < 0) goto on_error; - git_buf_dispose(&tag); + git_str_dispose(&tag); return 0; on_error: - git_buf_dispose(&tag); + git_str_dispose(&tag); git_error_set(GIT_ERROR_OBJECT, "failed to create tag annotation"); return -1; } @@ -255,7 +254,7 @@ static int git_tag_create__internal( int create_tag_annotation) { git_reference *new_ref = NULL; - git_buf ref_name = GIT_BUF_INIT; + git_str ref_name = GIT_STR_INIT; int error; @@ -276,7 +275,7 @@ static int git_tag_create__internal( /** Ensure the tag name doesn't conflict with an already existing * reference unless overwriting has explicitly been requested **/ if (error == 0 && !allow_ref_overwrite) { - git_buf_dispose(&ref_name); + git_str_dispose(&ref_name); git_error_set(GIT_ERROR_TAG, "tag already exists"); return GIT_EEXISTS; } @@ -291,7 +290,7 @@ static int git_tag_create__internal( cleanup: git_reference_free(new_ref); - git_buf_dispose(&ref_name); + git_str_dispose(&ref_name); return error; } @@ -344,7 +343,7 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b git_odb_object *target_obj; git_reference *new_ref = NULL; - git_buf ref_name = GIT_BUF_INIT; + git_str ref_name = GIT_STR_INIT; GIT_ASSERT_ARG(oid); GIT_ASSERT_ARG(buffer); @@ -395,7 +394,7 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b git_odb_stream_free(stream); if (error < 0) { - git_buf_dispose(&ref_name); + git_str_dispose(&ref_name); return error; } @@ -403,7 +402,7 @@ int git_tag_create_from_buffer(git_oid *oid, git_repository *repo, const char *b &new_ref, repo, ref_name.ptr, oid, allow_ref_overwrite, NULL); git_reference_free(new_ref); - git_buf_dispose(&ref_name); + git_str_dispose(&ref_name); return error; @@ -418,12 +417,12 @@ on_error: int git_tag_delete(git_repository *repo, const char *tag_name) { git_reference *tag_ref; - git_buf ref_name = GIT_BUF_INIT; + git_str ref_name = GIT_STR_INIT; int error; error = retrieve_tag_reference(&tag_ref, &ref_name, repo, tag_name); - git_buf_dispose(&ref_name); + git_str_dispose(&ref_name); if (error < 0) return error; @@ -535,7 +534,7 @@ int git_tag_peel(git_object **tag_target, const git_tag *tag) int git_tag_name_is_valid(int *valid, const char *name) { - git_buf ref_name = GIT_BUF_INIT; + git_str ref_name = GIT_STR_INIT; int error = 0; GIT_ASSERT(valid); @@ -547,14 +546,14 @@ int git_tag_name_is_valid(int *valid, const char *name) if (!name || name[0] == '-') goto done; - if ((error = git_buf_puts(&ref_name, GIT_REFS_TAGS_DIR)) < 0 || - (error = git_buf_puts(&ref_name, name)) < 0) + if ((error = git_str_puts(&ref_name, GIT_REFS_TAGS_DIR)) < 0 || + (error = git_str_puts(&ref_name, name)) < 0) goto done; error = git_reference_name_is_valid(valid, ref_name.ptr); done: - git_buf_dispose(&ref_name); + git_str_dispose(&ref_name); return error; } |