From b19b3b84745ea2e2af13a859ff7943c6de20fe4e Mon Sep 17 00:00:00 2001 From: Chris Marchesi Date: Fri, 7 Sep 2018 08:55:43 -0700 Subject: git: Don't touch tag objects orphaned by tag deletion Deleting a tag ref for an annotated tag in normal git behavior does not delete the tag object right away. This is handled by the normal GC process. Signed-off-by: Chris Marchesi --- repository.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'repository.go') diff --git a/repository.go b/repository.go index 67bc96a..096ec13 100644 --- a/repository.go +++ b/repository.go @@ -617,26 +617,12 @@ func (r *Repository) Tag(name string) (*plumbing.Reference, error) { // DeleteTag deletes a tag from the repository. func (r *Repository) DeleteTag(name string) error { - ref, err := r.Tag(name) + _, err := r.Tag(name) if err != nil { return err } - obj, err := r.TagObject(ref.Hash()) - if err != nil && err != plumbing.ErrObjectNotFound { - return err - } - - if err = r.Storer.RemoveReference(plumbing.ReferenceName(path.Join("refs", "tags", name))); err != nil { - return err - } - - // Delete the tag object if this was an annotated tag. - if obj != nil { - return r.DeleteObject(obj.Hash) - } - - return nil + return r.Storer.RemoveReference(plumbing.ReferenceName(path.Join("refs", "tags", name))) } func (r *Repository) resolveToCommitHash(h plumbing.Hash) (plumbing.Hash, error) { -- cgit