@@ -279,7 +279,7 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (storer.ReferenceSt
279279 }
280280 }
281281
282- updated , err := r .updateLocalReferenceStorage (o .RefSpecs , refs , remoteRefs )
282+ updated , err := r .updateLocalReferenceStorage (o .RefSpecs , refs , remoteRefs , o . Tags )
283283 if err != nil {
284284 return nil , err
285285 }
@@ -481,10 +481,17 @@ func getHaves(localRefs storer.ReferenceStorer) ([]plumbing.Hash, error) {
481481 return result , nil
482482}
483483
484- func calculateRefs (spec []config.RefSpec ,
484+ const refspecTag = "+refs/tags/*:refs/tags/*"
485+
486+ func calculateRefs (
487+ spec []config.RefSpec ,
485488 remoteRefs storer.ReferenceStorer ,
486- tags TagFetchMode ,
489+ tagMode TagMode ,
487490) (memory.ReferenceStorage , error ) {
491+ if tagMode == AllTags {
492+ spec = append (spec , refspecTag )
493+ }
494+
488495 iter , err := remoteRefs .IterReferences ()
489496 if err != nil {
490497 return nil , err
@@ -493,9 +500,7 @@ func calculateRefs(spec []config.RefSpec,
493500 refs := make (memory.ReferenceStorage , 0 )
494501 return refs , iter .ForEach (func (ref * plumbing.Reference ) error {
495502 if ! config .MatchAny (spec , ref .Name ()) {
496- if ! ref .Name ().IsTag () || tags != AllTags {
497- return nil
498- }
503+ return nil
499504 }
500505
501506 if ref .Type () == plumbing .SymbolicReference {
@@ -645,6 +650,7 @@ func buildSidebandIfSupported(l *capability.List, reader io.Reader, p sideband.P
645650func (r * Remote ) updateLocalReferenceStorage (
646651 specs []config.RefSpec ,
647652 fetchedRefs , remoteRefs memory.ReferenceStorage ,
653+ tagMode TagMode ,
648654) (updated bool , err error ) {
649655 isWildcard := true
650656 for _ , spec := range specs {
@@ -674,6 +680,10 @@ func (r *Remote) updateLocalReferenceStorage(
674680 }
675681 }
676682
683+ if tagMode == NoTags {
684+ return updated , nil
685+ }
686+
677687 tags := fetchedRefs
678688 if isWildcard {
679689 tags = remoteRefs
0 commit comments