aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit.go
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2017-11-27 16:21:44 -0800
committerJeremy Stribling <strib@alum.mit.edu>2017-11-27 16:22:16 -0800
commit9c80677ec0d1778e6d304b235a22f4e636322e74 (patch)
tree5f4d4f6d1da3f19ef7c0d78d67a24677c18f354c /storage/filesystem/internal/dotgit/dotgit.go
parent129ff16f8686bb74a206cf58000de1d9640e370a (diff)
downloadgo-git-9c80677ec0d1778e6d304b235a22f4e636322e74.tar.gz
dotgit: don't list references twice
Restore the `seen` map that avoided listing packed-refs twice.
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 43d0e2d..8e5381c 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -268,7 +268,7 @@ func (d *DotGit) Refs() ([]*plumbing.Reference, error) {
return nil, err
}
- if err := d.addRefsFromPackedRefs(&refs); err != nil {
+ if err := d.addRefsFromPackedRefs(&refs, seen); err != nil {
return nil, err
}
@@ -347,13 +347,18 @@ func (d *DotGit) RemoveRef(name plumbing.ReferenceName) error {
return d.rewritePackedRefsWithoutRef(name)
}
-func (d *DotGit) addRefsFromPackedRefs(refs *[]*plumbing.Reference) (err error) {
+func (d *DotGit) addRefsFromPackedRefs(refs *[]*plumbing.Reference, seen map[plumbing.ReferenceName]bool) (err error) {
packedRefs, err := d.findPackedRefs()
if err != nil {
return err
}
- *refs = append(*refs, packedRefs...)
+ for _, ref := range packedRefs {
+ if !seen[ref.Name()] {
+ *refs = append(*refs, ref)
+ seen[ref.Name()] = true
+ }
+ }
return nil
}