Skip to content

Commit

Permalink
git: Don't touch tag objects orphaned by tag deletion
Browse files Browse the repository at this point in the history
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 <chrism@vancluevertech.com>
  • Loading branch information
vancluever committed Sep 7, 2018
1 parent 1000bc0 commit b19b3b8
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b19b3b8

Please sign in to comment.