diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-13 13:21:36 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-13 13:21:36 +0200 |
commit | c0de8847ecbb20c99e652a8db5edc883c0e2f9ba (patch) | |
tree | 1027789d4692c5da82cc1e87606a48de42796371 /remote.go | |
parent | 6b3a6df29920d39b8308924b3b84178226b56224 (diff) | |
download | go-git-c0de8847ecbb20c99e652a8db5edc883c0e2f9ba.tar.gz |
remote: avoid duplicate haves
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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( |