diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-13 01:51:00 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-13 01:51:00 +0200 |
commit | a6ea9e8dd2eda48c8405f609e0fb444d3717af53 (patch) | |
tree | a2815bca686619d10151a531cddf5a7fdadedffa /clients/common | |
parent | ae999ede139f5fa5601ffb7c55979608b112d274 (diff) | |
download | go-git-a6ea9e8dd2eda48c8405f609e0fb444d3717af53.tar.gz |
Repository and Remote API changes
Diffstat (limited to 'clients/common')
-rw-r--r-- | clients/common/common.go | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/clients/common/common.go b/clients/common/common.go index a09f2d8..fbd8066 100644 --- a/clients/common/common.go +++ b/clients/common/common.go @@ -10,6 +10,7 @@ import ( "gopkg.in/src-d/go-git.v4/core" "gopkg.in/src-d/go-git.v4/formats/pktline" + "gopkg.in/src-d/go-git.v4/storage/memory" "gopkg.in/sourcegraph/go-vcsurl.v1" ) @@ -180,7 +181,7 @@ func (c *Capabilities) String() string { type GitUploadPackInfo struct { Capabilities *Capabilities - Refs map[core.ReferenceName]*core.Reference + Refs memory.ReferenceStorage } func NewGitUploadPackInfo() *GitUploadPackInfo { @@ -206,7 +207,7 @@ func (r *GitUploadPackInfo) read(d *pktline.Decoder) error { } isEmpty := true - r.Refs = map[core.ReferenceName]*core.Reference{} + r.Refs = make(memory.ReferenceStorage, 0) for _, line := range lines { if !r.isValidLine(line) { continue @@ -237,7 +238,7 @@ func (r *GitUploadPackInfo) decodeHeaderLine(line string) { } refName := core.ReferenceName(name) - r.Refs[core.HEAD] = core.NewSymbolicReference(core.HEAD, refName) + r.Refs.Set(core.NewSymbolicReference(core.HEAD, refName)) } func (r *GitUploadPackInfo) isValidLine(line string) bool { @@ -250,21 +251,11 @@ func (r *GitUploadPackInfo) readLine(line string) { return } - ref := core.NewReferenceFromStrings(parts[1], parts[0]) - r.Refs[ref.Name()] = ref + r.Refs.Set(core.NewReferenceFromStrings(parts[1], parts[0])) } func (r *GitUploadPackInfo) Head() *core.Reference { - h, ok := r.Refs[core.HEAD] - if !ok { - return nil - } - - ref, ok := r.Refs[h.Target()] - if !ok { - return nil - } - + ref, _ := core.ResolveReference(r.Refs, core.HEAD) return ref } |