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 7ebb843..4c2643b 100644
--- a/remote.go
+++ b/remote.go
@@ -356,20 +356,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 getWants(