aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/remote.go b/remote.go
index b2c5d1c..8f1da2f 100644
--- a/remote.go
+++ b/remote.go
@@ -362,20 +362,30 @@ func getHaves(localRefs storer.ReferenceStorer) ([]plumbing.Hash, error) {
return nil, err
}
- var haves []plumbing.Hash
+ haves := map[plumbing.Hash]bool{}
err = iter.ForEach(func(ref *plumbing.Reference) error {
+ if haves[ref.Hash()] == true {
+ return nil
+ }
+
if ref.Type() != plumbing.HashReference {
return nil
}
- haves = append(haves, ref.Hash())
+ haves[ref.Hash()] = true
return nil
})
+
if err != nil {
return nil, err
}
- return haves, nil
+ var result []plumbing.Hash
+ for h := range haves {
+ result = append(result, h)
+ }
+
+ return result, nil
}
func calculateRefs(spec []config.RefSpec,