aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-13 13:21:36 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-07-13 13:21:36 +0200
commitc0de8847ecbb20c99e652a8db5edc883c0e2f9ba (patch)
tree1027789d4692c5da82cc1e87606a48de42796371 /remote.go
parent6b3a6df29920d39b8308924b3b84178226b56224 (diff)
downloadgo-git-c0de8847ecbb20c99e652a8db5edc883c0e2f9ba.tar.gz
remote: avoid duplicate haves
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(