Skip to content

Instantly share code, notes, and snippets.

@kiryl
Created August 24, 2011 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiryl/1167736 to your computer and use it in GitHub Desktop.
Save kiryl/1167736 to your computer and use it in GitHub Desktop.
typedef struct git_repository git_repository;
typedef struct git_reference git_reference;
extern int git__rethrow(int error, const char *, ...);
void git_path_join(char *buffer_out, const char *path_a, const char *path_b);
int git_reference_lookup(git_reference **reference_out, git_repository *repo, const char *name);
int git_reference_delete(git_reference *ref);
static int retrieve_tag_reference(git_reference **tag_reference_out, char *ref_name_out, git_repository *repo, const char *tag_name)
{
git_reference *tag_ref;
int error;
git_path_join(ref_name_out, "refs/" "tags/", tag_name);
error = git_reference_lookup(&tag_ref, repo, ref_name_out);
if (error < 0)
return git__rethrow(error, "Failed to retrieve tag reference");
*tag_reference_out = tag_ref;
return 0;
}
int git_tag_delete(git_repository *repo, const char *tag_name)
{
int error;
git_reference *tag_ref;
char ref_name[1024];
error = retrieve_tag_reference(&tag_ref, ref_name, repo, tag_name);
if (error < 0)
return git__rethrow(error, "Failed to delete tag");
return git_reference_delete(tag_ref);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment