From 65886144d1e19b563c4e8854ba1cd0d532fea532 Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Thu, 1 Mar 2018 17:00:05 +0000 Subject: remove unused result parameter from objectsToPush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It always returns a nil error. Signed-off-by: Daniel Martí --- remote.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/remote.go b/remote.go index 8828e3f..8db645c 100644 --- a/remote.go +++ b/remote.go @@ -130,10 +130,7 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error { return NoErrAlreadyUpToDate } - objects, err := objectsToPush(req.Commands) - if err != nil { - return err - } + objects := objectsToPush(req.Commands) haves, err := referencesToHashes(remoteRefs) if err != nil { @@ -907,7 +904,7 @@ func (r *Remote) List(o *ListOptions) ([]*plumbing.Reference, error) { return resultRefs, nil } -func objectsToPush(commands []*packp.Command) ([]plumbing.Hash, error) { +func objectsToPush(commands []*packp.Command) []plumbing.Hash { var objects []plumbing.Hash for _, cmd := range commands { if cmd.New == plumbing.ZeroHash { @@ -916,8 +913,7 @@ func objectsToPush(commands []*packp.Command) ([]plumbing.Hash, error) { objects = append(objects, cmd.New) } - - return objects, nil + return objects } func referencesToHashes(refs storer.ReferenceStorer) ([]plumbing.Hash, error) { -- cgit From ede92fa7ff9a6c5a61245e2ebeaa4d3929a37ce8 Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Thu, 1 Mar 2018 17:03:32 +0000 Subject: all: remove some unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Martí --- plumbing/cache/queue.go | 46 ---------------------------- plumbing/storer/object.go | 2 -- plumbing/transport/server/server.go | 11 ------- storage/filesystem/internal/dotgit/dotgit.go | 2 -- worktree.go | 4 --- 5 files changed, 65 deletions(-) delete mode 100644 plumbing/cache/queue.go diff --git a/plumbing/cache/queue.go b/plumbing/cache/queue.go deleted file mode 100644 index 85413e0..0000000 --- a/plumbing/cache/queue.go +++ /dev/null @@ -1,46 +0,0 @@ -package cache - -import "gopkg.in/src-d/go-git.v4/plumbing" - -// queue is a basic FIFO queue based on a circular list that resize as needed. -type queue struct { - elements []plumbing.Hash - size int - head int - tail int - count int -} - -// newQueue returns a queue with the specified initial size -func newQueue(size int) *queue { - return &queue{ - elements: make([]plumbing.Hash, size), - size: size, - } -} - -// Push adds a node to the queue. -func (q *queue) Push(h plumbing.Hash) { - if q.head == q.tail && q.count > 0 { - elements := make([]plumbing.Hash, len(q.elements)+q.size) - copy(elements, q.elements[q.head:]) - copy(elements[len(q.elements)-q.head:], q.elements[:q.head]) - q.head = 0 - q.tail = len(q.elements) - q.elements = elements - } - q.elements[q.tail] = h - q.tail = (q.tail + 1) % len(q.elements) - q.count++ -} - -// Pop removes and returns a Hash from the queue in first to last order. -func (q *queue) Pop() plumbing.Hash { - if q.count == 0 { - return plumbing.ZeroHash - } - node := q.elements[q.head] - q.head = (q.head + 1) % len(q.elements) - q.count-- - return node -} diff --git a/plumbing/storer/object.go b/plumbing/storer/object.go index f1d19ef..92aa629 100644 --- a/plumbing/storer/object.go +++ b/plumbing/storer/object.go @@ -174,7 +174,6 @@ func (iter *EncodedObjectLookupIter) Close() { // no longer needed. type EncodedObjectSliceIter struct { series []plumbing.EncodedObject - pos int } // NewEncodedObjectSliceIter returns an object iterator for the given slice of @@ -218,7 +217,6 @@ func (iter *EncodedObjectSliceIter) Close() { // longer needed. type MultiEncodedObjectIter struct { iters []EncodedObjectIter - pos int } // NewMultiEncodedObjectIter returns an object iterator for the given slice of diff --git a/plumbing/transport/server/server.go b/plumbing/transport/server/server.go index 2357bd6..20bd12e 100644 --- a/plumbing/transport/server/server.go +++ b/plumbing/transport/server/server.go @@ -298,17 +298,6 @@ func (s *rpSession) updateReferences(req *packp.ReferenceUpdateRequest) { } } -func (s *rpSession) failAtomicUpdate() (*packp.ReportStatus, error) { - rs := s.reportStatus() - for _, cs := range rs.CommandStatuses { - if cs.Error() == nil { - cs.Status = "atomic updated" - } - } - - return rs, s.firstErr -} - func (s *rpSession) writePackfile(r io.ReadCloser) error { if r == nil { return nil diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go index fac7aec..027ef83 100644 --- a/storage/filesystem/internal/dotgit/dotgit.go +++ b/storage/filesystem/internal/dotgit/dotgit.go @@ -798,5 +798,3 @@ func isNum(b byte) bool { func isHexAlpha(b byte) bool { return b >= 'a' && b <= 'f' || b >= 'A' && b <= 'F' } - -type refCache map[plumbing.ReferenceName]*plumbing.Reference diff --git a/worktree.go b/worktree.go index a23397e..394dce4 100644 --- a/worktree.go +++ b/worktree.go @@ -607,10 +607,6 @@ func (w *Worktree) getTreeFromCommitHash(commit plumbing.Hash) (*object.Tree, er return c.Tree() } -func (w *Worktree) initializeIndex() error { - return w.r.Storer.SetIndex(&index.Index{Version: 2}) -} - var fillSystemInfo func(e *index.Entry, sys interface{}) const gitmodulesFile = ".gitmodules" -- cgit From e850aea5005fdb2a74d7dcd3267dac4a3612df8a Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Thu, 1 Mar 2018 17:09:42 +0000 Subject: all: make the upcoming Go 1.11's vet happy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vet in 1.10 and earlier was buggy in how its "composite literal uses unkeyed fields" check had false negatives when it encountered a slice of pointer types that omitted each element's type. This has been fixed in tip, so adapt to that fix. Signed-off-by: Daniel Martí --- plumbing/transport/test/receive_pack.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plumbing/transport/test/receive_pack.go b/plumbing/transport/test/receive_pack.go index 0f3352c..a68329e 100644 --- a/plumbing/transport/test/receive_pack.go +++ b/plumbing/transport/test/receive_pack.go @@ -50,7 +50,7 @@ func (s *ReceivePackSuite) TestAdvertisedReferencesNotExists(c *C) { c.Assert(err, IsNil) req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"master", plumbing.ZeroHash, plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")}, + {Name: "master", Old: plumbing.ZeroHash, New: plumbing.NewHash("6ecf0ef2c2dffb796033e5a02219af86ec6584e5")}, } writer, err := r.ReceivePack(context.Background(), req) @@ -99,7 +99,7 @@ func (s *ReceivePackSuite) TestFullSendPackOnEmpty(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {Name: "refs/heads/master", Old: plumbing.ZeroHash, New: fixture.Head}, } s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) @@ -110,7 +110,7 @@ func (s *ReceivePackSuite) TestSendPackWithContext(c *C) { req := packp.NewReferenceUpdateRequest() req.Packfile = fixture.Packfile() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {Name: "refs/heads/master", Old: plumbing.ZeroHash, New: fixture.Head}, } r, err := s.Client.NewReceivePackSession(s.EmptyEndpoint, s.EmptyAuth) @@ -135,7 +135,7 @@ func (s *ReceivePackSuite) TestSendPackOnEmpty(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {Name: "refs/heads/master", Old: plumbing.ZeroHash, New: fixture.Head}, } s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) @@ -147,7 +147,7 @@ func (s *ReceivePackSuite) TestSendPackOnEmptyWithReportStatus(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {Name: "refs/heads/master", Old: plumbing.ZeroHash, New: fixture.Head}, } req.Capabilities.Set(capability.ReportStatus) s.receivePack(c, endpoint, req, fixture, full) @@ -160,7 +160,7 @@ func (s *ReceivePackSuite) TestFullSendPackOnNonEmpty(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", fixture.Head, fixture.Head}, + {Name: "refs/heads/master", Old: fixture.Head, New: fixture.Head}, } s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) @@ -172,7 +172,7 @@ func (s *ReceivePackSuite) TestSendPackOnNonEmpty(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", fixture.Head, fixture.Head}, + {Name: "refs/heads/master", Old: fixture.Head, New: fixture.Head}, } s.receivePack(c, endpoint, req, fixture, full) s.checkRemoteHead(c, endpoint, fixture.Head) @@ -184,7 +184,7 @@ func (s *ReceivePackSuite) TestSendPackOnNonEmptyWithReportStatus(c *C) { fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", fixture.Head, fixture.Head}, + {Name: "refs/heads/master", Old: fixture.Head, New: fixture.Head}, } req.Capabilities.Set(capability.ReportStatus) @@ -198,7 +198,7 @@ func (s *ReceivePackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C) fixture := fixtures.Basic().ByTag("packfile").One() req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/master", plumbing.ZeroHash, fixture.Head}, + {Name: "refs/heads/master", Old: plumbing.ZeroHash, New: fixture.Head}, } req.Capabilities.Set(capability.ReportStatus) @@ -306,7 +306,7 @@ func (s *ReceivePackSuite) testSendPackAddReference(c *C) { req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/newbranch", plumbing.ZeroHash, fixture.Head}, + {Name: "refs/heads/newbranch", Old: plumbing.ZeroHash, New: fixture.Head}, } if ar.Capabilities.Supports(capability.ReportStatus) { req.Capabilities.Set(capability.ReportStatus) @@ -329,7 +329,7 @@ func (s *ReceivePackSuite) testSendPackDeleteReference(c *C) { req := packp.NewReferenceUpdateRequest() req.Commands = []*packp.Command{ - {"refs/heads/newbranch", fixture.Head, plumbing.ZeroHash}, + {Name: "refs/heads/newbranch", Old: fixture.Head, New: plumbing.ZeroHash}, } if ar.Capabilities.Supports(capability.ReportStatus) { req.Capabilities.Set(capability.ReportStatus) -- cgit