aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--blame_test.go2
-rw-r--r--config/branch_test.go3
-rw-r--r--internal/revision/parser_test.go16
-rw-r--r--plumbing/format/commitgraph/commitgraph_test.go5
-rw-r--r--plumbing/format/config/option.go2
-rw-r--r--plumbing/format/config/section.go2
-rw-r--r--plumbing/format/idxfile/encoder_test.go2
-rw-r--r--plumbing/format/idxfile/idxfile_test.go2
-rw-r--r--plumbing/format/idxfile/writer_test.go2
-rw-r--r--plumbing/format/index/decoder.go4
-rw-r--r--plumbing/format/index/decoder_test.go2
-rw-r--r--plumbing/format/index/encoder_test.go3
-rw-r--r--plumbing/format/objfile/common_test.go3
-rw-r--r--plumbing/format/objfile/reader_test.go3
-rw-r--r--plumbing/format/objfile/writer_test.go3
-rw-r--r--plumbing/format/packfile/encoder_advanced_test.go4
-rw-r--r--plumbing/format/packfile/encoder_test.go4
-rw-r--r--plumbing/format/packfile/patch_delta.go3
-rw-r--r--plumbing/memory.go17
-rw-r--r--plumbing/memory_test.go28
-rw-r--r--plumbing/object/commit.go24
-rw-r--r--plumbing/object/commit_stats_test.go3
-rw-r--r--plumbing/object/commit_walker_bfs_filtered.go1
-rw-r--r--plumbing/object/commit_walker_path.go3
-rw-r--r--plumbing/object/commitgraph/commitnode_test.go5
-rw-r--r--plumbing/object/commitgraph/commitnode_walker_ctime.go4
-rw-r--r--plumbing/object/file_test.go2
-rw-r--r--plumbing/object/patch.go16
-rw-r--r--plumbing/object/patch_test.go5
-rw-r--r--plumbing/object/rename.go6
-rw-r--r--plumbing/protocol/packp/ulreq.go32
-rw-r--r--plumbing/protocol/packp/ulreq_decode.go4
-rw-r--r--plumbing/protocol/packp/ulreq_encode.go4
-rw-r--r--plumbing/protocol/packp/updreq.go6
-rw-r--r--plumbing/protocol/packp/updreq_encode.go18
-rw-r--r--plumbing/protocol/packp/uppackresp_test.go2
-rw-r--r--plumbing/storer/object_test.go3
-rw-r--r--plumbing/storer/reference_test.go3
-rw-r--r--plumbing/transport/file/receive_pack_test.go2
-rw-r--r--plumbing/transport/git/common_test.go2
-rw-r--r--plumbing/transport/git/receive_pack_test.go2
-rw-r--r--plumbing/transport/git/upload_pack_test.go2
-rw-r--r--plumbing/transport/http/common_test.go2
-rw-r--r--plumbing/transport/http/receive_pack_test.go2
-rw-r--r--plumbing/transport/http/upload_pack_test.go2
-rw-r--r--plumbing/transport/server/receive_pack_test.go1
-rw-r--r--plumbing/transport/ssh/common_test.go5
-rw-r--r--plumbing/transport/test/upload_pack.go2
-rw-r--r--prune_test.go2
-rw-r--r--references_test.go2
-rw-r--r--remote.go10
-rw-r--r--repository.go4
-rw-r--r--repository_test.go1
-rw-r--r--storage/filesystem/config_test.go4
-rw-r--r--storage/filesystem/dotgit/writers_test.go2
-rw-r--r--storage/memory/storage.go4
-rw-r--r--storage/transactional/config_test.go3
-rw-r--r--storage/transactional/index_test.go3
-rw-r--r--storage/transactional/object_test.go3
-rw-r--r--storage/transactional/reference_test.go3
-rw-r--r--storage/transactional/shallow_test.go3
-rw-r--r--submodule_test.go2
-rw-r--r--utils/binary/read_test.go3
-rw-r--r--utils/diff/diff.go2
-rw-r--r--utils/merkletrie/filesystem/node.go3
-rw-r--r--utils/merkletrie/filesystem/node_test.go7
-rw-r--r--utils/merkletrie/index/node_test.go3
-rw-r--r--worktree.go3
-rw-r--r--worktree_commit.go2
69 files changed, 200 insertions, 142 deletions
diff --git a/blame_test.go b/blame_test.go
index 398f839..7895b66 100644
--- a/blame_test.go
+++ b/blame_test.go
@@ -4,8 +4,8 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type BlameSuite struct {
diff --git a/config/branch_test.go b/config/branch_test.go
index a2c86cd..ae1fe85 100644
--- a/config/branch_test.go
+++ b/config/branch_test.go
@@ -1,8 +1,9 @@
package config
import (
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
type BranchSuite struct{}
diff --git a/internal/revision/parser_test.go b/internal/revision/parser_test.go
index fe45228..4bb007f 100644
--- a/internal/revision/parser_test.go
+++ b/internal/revision/parser_test.go
@@ -96,8 +96,8 @@ func (s *ParserSuite) TestParseWithValidExpression(c *C) {
TildePath{3},
},
"@{2016-12-16T21:42:47Z}": []Revisioner{AtDate{tim}},
- "@{1}": []Revisioner{AtReflog{1}},
- "@{-1}": []Revisioner{AtCheckout{1}},
+ "@{1}": []Revisioner{AtReflog{1}},
+ "@{-1}": []Revisioner{AtCheckout{1}},
"master@{upstream}": []Revisioner{
Ref("master"),
AtUpstream{},
@@ -211,12 +211,12 @@ func (s *ParserSuite) TestParseAtWithValidExpression(c *C) {
tim, _ := time.Parse("2006-01-02T15:04:05Z", "2016-12-16T21:42:47Z")
datas := map[string]Revisioner{
- "": Ref("HEAD"),
- "{1}": AtReflog{1},
- "{-1}": AtCheckout{1},
- "{push}": AtPush{},
- "{upstream}": AtUpstream{},
- "{u}": AtUpstream{},
+ "": Ref("HEAD"),
+ "{1}": AtReflog{1},
+ "{-1}": AtCheckout{1},
+ "{push}": AtPush{},
+ "{upstream}": AtUpstream{},
+ "{u}": AtUpstream{},
"{2016-12-16T21:42:47Z}": AtDate{tim},
}
diff --git a/plumbing/format/commitgraph/commitgraph_test.go b/plumbing/format/commitgraph/commitgraph_test.go
index 7d7444b..de61ae9 100644
--- a/plumbing/format/commitgraph/commitgraph_test.go
+++ b/plumbing/format/commitgraph/commitgraph_test.go
@@ -6,10 +6,11 @@ import (
"path"
"testing"
- . "gopkg.in/check.v1"
- fixtures "github.com/go-git/go-git-fixtures/v4"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/commitgraph"
+
+ fixtures "github.com/go-git/go-git-fixtures/v4"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/format/config/option.go b/plumbing/format/config/option.go
index d4775e4..218f992 100644
--- a/plumbing/format/config/option.go
+++ b/plumbing/format/config/option.go
@@ -19,7 +19,7 @@ type Options []*Option
// IsKey returns true if the given key matches
// this option's key in a case-insensitive comparison.
func (o *Option) IsKey(key string) bool {
- return strings.ToLower(o.Key) == strings.ToLower(key)
+ return strings.EqualFold(o.Key, key)
}
func (opts Options) GoString() string {
diff --git a/plumbing/format/config/section.go b/plumbing/format/config/section.go
index 4a17e3b..f743da6 100644
--- a/plumbing/format/config/section.go
+++ b/plumbing/format/config/section.go
@@ -61,7 +61,7 @@ func (s Subsections) GoString() string {
// IsName checks if the name provided is equals to the Section name, case insensitive.
func (s *Section) IsName(name string) bool {
- return strings.ToLower(s.Name) == strings.ToLower(name)
+ return strings.EqualFold(s.Name, name)
}
// Option return the value for the specified key. Empty string is returned if
diff --git a/plumbing/format/idxfile/encoder_test.go b/plumbing/format/idxfile/encoder_test.go
index 81abb3b..32b60f9 100644
--- a/plumbing/format/idxfile/encoder_test.go
+++ b/plumbing/format/idxfile/encoder_test.go
@@ -6,8 +6,8 @@ import (
. "github.com/go-git/go-git/v5/plumbing/format/idxfile"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
func (s *IdxfileSuite) TestDecodeEncode(c *C) {
diff --git a/plumbing/format/idxfile/idxfile_test.go b/plumbing/format/idxfile/idxfile_test.go
index 5ef73d7..7a3d6bb 100644
--- a/plumbing/format/idxfile/idxfile_test.go
+++ b/plumbing/format/idxfile/idxfile_test.go
@@ -10,8 +10,8 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/idxfile"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
func BenchmarkFindOffset(b *testing.B) {
diff --git a/plumbing/format/idxfile/writer_test.go b/plumbing/format/idxfile/writer_test.go
index f86342f..fba3e42 100644
--- a/plumbing/format/idxfile/writer_test.go
+++ b/plumbing/format/idxfile/writer_test.go
@@ -9,8 +9,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/idxfile"
"github.com/go-git/go-git/v5/plumbing/format/packfile"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type WriterSuite struct {
diff --git a/plumbing/format/index/decoder.go b/plumbing/format/index/decoder.go
index 79d0b9e..d341d59 100644
--- a/plumbing/format/index/decoder.go
+++ b/plumbing/format/index/decoder.go
@@ -390,7 +390,9 @@ func (d *treeExtensionDecoder) readEntry() (*TreeEntry, error) {
e.Trees = i
_, err = io.ReadFull(d.r, e.Hash[:])
-
+ if err != nil {
+ return nil, err
+ }
return e, nil
}
diff --git a/plumbing/format/index/decoder_test.go b/plumbing/format/index/decoder_test.go
index 4e47dde..39ab336 100644
--- a/plumbing/format/index/decoder_test.go
+++ b/plumbing/format/index/decoder_test.go
@@ -6,8 +6,8 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/filemode"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/format/index/encoder_test.go b/plumbing/format/index/encoder_test.go
index 17585a0..b7a73cb 100644
--- a/plumbing/format/index/encoder_test.go
+++ b/plumbing/format/index/encoder_test.go
@@ -5,9 +5,10 @@ import (
"strings"
"time"
+ "github.com/go-git/go-git/v5/plumbing"
+
"github.com/google/go-cmp/cmp"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git/v5/plumbing"
)
func (s *IndexSuite) TestEncode(c *C) {
diff --git a/plumbing/format/objfile/common_test.go b/plumbing/format/objfile/common_test.go
index ec8c280..de76902 100644
--- a/plumbing/format/objfile/common_test.go
+++ b/plumbing/format/objfile/common_test.go
@@ -4,8 +4,9 @@ import (
"encoding/base64"
"testing"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
type objfileFixture struct {
diff --git a/plumbing/format/objfile/reader_test.go b/plumbing/format/objfile/reader_test.go
index 48e7f1c..d697d54 100644
--- a/plumbing/format/objfile/reader_test.go
+++ b/plumbing/format/objfile/reader_test.go
@@ -7,8 +7,9 @@ import (
"io"
"io/ioutil"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
type SuiteReader struct{}
diff --git a/plumbing/format/objfile/writer_test.go b/plumbing/format/objfile/writer_test.go
index 73ee662..35a9510 100644
--- a/plumbing/format/objfile/writer_test.go
+++ b/plumbing/format/objfile/writer_test.go
@@ -6,8 +6,9 @@ import (
"fmt"
"io"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
type SuiteWriter struct{}
diff --git a/plumbing/format/packfile/encoder_advanced_test.go b/plumbing/format/packfile/encoder_advanced_test.go
index 21bf3ae..95db5c0 100644
--- a/plumbing/format/packfile/encoder_advanced_test.go
+++ b/plumbing/format/packfile/encoder_advanced_test.go
@@ -6,7 +6,6 @@ import (
"math/rand"
"testing"
- "github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/format/idxfile"
@@ -14,8 +13,9 @@ import (
"github.com/go-git/go-git/v5/plumbing/storer"
"github.com/go-git/go-git/v5/storage/filesystem"
+ "github.com/go-git/go-billy/v5/memfs"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type EncoderAdvancedSuite struct {
diff --git a/plumbing/format/packfile/encoder_test.go b/plumbing/format/packfile/encoder_test.go
index 2689762..d2db892 100644
--- a/plumbing/format/packfile/encoder_test.go
+++ b/plumbing/format/packfile/encoder_test.go
@@ -5,13 +5,13 @@ import (
"io"
stdioutil "io/ioutil"
- "github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/idxfile"
"github.com/go-git/go-git/v5/storage/memory"
+ "github.com/go-git/go-billy/v5/memfs"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type EncoderSuite struct {
diff --git a/plumbing/format/packfile/patch_delta.go b/plumbing/format/packfile/patch_delta.go
index 1dc8b8b..9e90f30 100644
--- a/plumbing/format/packfile/patch_delta.go
+++ b/plumbing/format/packfile/patch_delta.go
@@ -49,7 +49,6 @@ func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) (err error) {
return err
}
-
target.SetSize(int64(dst.Len()))
b := byteSlicePool.Get().([]byte)
@@ -113,7 +112,7 @@ func patchDelta(dst *bytes.Buffer, src, delta []byte) error {
invalidOffsetSize(offset, sz, srcSz) {
break
}
- dst.Write(src[offset:offset+sz])
+ dst.Write(src[offset : offset+sz])
remainingTargetSz -= sz
} else if isCopyFromDelta(cmd) {
sz := uint(cmd) // cmd is the size itself
diff --git a/plumbing/memory.go b/plumbing/memory.go
index b8e1e1b..21337cc 100644
--- a/plumbing/memory.go
+++ b/plumbing/memory.go
@@ -3,7 +3,6 @@ package plumbing
import (
"bytes"
"io"
- "io/ioutil"
)
// MemoryObject on memory Object implementation
@@ -39,9 +38,11 @@ func (o *MemoryObject) Size() int64 { return o.sz }
// afterwards
func (o *MemoryObject) SetSize(s int64) { o.sz = s }
-// Reader returns a ObjectReader used to read the object's content.
+// Reader returns an io.ReadCloser used to read the object's content.
+//
+// For a MemoryObject, this reader is seekable.
func (o *MemoryObject) Reader() (io.ReadCloser, error) {
- return ioutil.NopCloser(bytes.NewBuffer(o.cont)), nil
+ return nopCloser{bytes.NewReader(o.cont)}, nil
}
// Writer returns a ObjectWriter used to write the object's content.
@@ -59,3 +60,13 @@ func (o *MemoryObject) Write(p []byte) (n int, err error) {
// Close releases any resources consumed by the object when it is acting as a
// ObjectWriter.
func (o *MemoryObject) Close() error { return nil }
+
+// nopCloser exposes the extra methods of bytes.Reader while nopping Close().
+//
+// This allows clients to attempt seeking in a cached Blob's Reader.
+type nopCloser struct {
+ *bytes.Reader
+}
+
+// Close does nothing.
+func (nc nopCloser) Close() error { return nil }
diff --git a/plumbing/memory_test.go b/plumbing/memory_test.go
index 879ed37..2a141f4 100644
--- a/plumbing/memory_test.go
+++ b/plumbing/memory_test.go
@@ -1,6 +1,7 @@
package plumbing
import (
+ "io"
"io/ioutil"
. "gopkg.in/check.v1"
@@ -56,6 +57,33 @@ func (s *MemoryObjectSuite) TestReader(c *C) {
c.Assert(b, DeepEquals, []byte("foo"))
}
+func (s *MemoryObjectSuite) TestSeekableReader(c *C) {
+ const pageSize = 4096
+ const payload = "foo"
+ content := make([]byte, pageSize+len(payload))
+ copy(content[pageSize:], []byte(payload))
+
+ o := &MemoryObject{cont: content}
+
+ reader, err := o.Reader()
+ c.Assert(err, IsNil)
+ defer func() { c.Assert(reader.Close(), IsNil) }()
+
+ rs, ok := reader.(io.ReadSeeker)
+ c.Assert(ok, Equals, true)
+
+ _, err = rs.Seek(pageSize, io.SeekStart)
+ c.Assert(err, IsNil)
+
+ b, err := ioutil.ReadAll(rs)
+ c.Assert(err, IsNil)
+ c.Assert(b, DeepEquals, []byte(payload))
+
+ // Check that our Reader isn't also accidentally writable
+ _, ok = reader.(io.WriteSeeker)
+ c.Assert(ok, Equals, false)
+}
+
func (s *MemoryObjectSuite) TestWriter(c *C) {
o := &MemoryObject{}
diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go
index 113cb29..98664a1 100644
--- a/plumbing/object/commit.go
+++ b/plumbing/object/commit.go
@@ -243,16 +243,16 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) {
}
// Encode transforms a Commit into a plumbing.EncodedObject.
-func (b *Commit) Encode(o plumbing.EncodedObject) error {
- return b.encode(o, true)
+func (c *Commit) Encode(o plumbing.EncodedObject) error {
+ return c.encode(o, true)
}
// EncodeWithoutSignature export a Commit into a plumbing.EncodedObject without the signature (correspond to the payload of the PGP signature).
-func (b *Commit) EncodeWithoutSignature(o plumbing.EncodedObject) error {
- return b.encode(o, false)
+func (c *Commit) EncodeWithoutSignature(o plumbing.EncodedObject) error {
+ return c.encode(o, false)
}
-func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
+func (c *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
o.SetType(plumbing.CommitObject)
w, err := o.Writer()
if err != nil {
@@ -261,11 +261,11 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
defer ioutil.CheckClose(w, &err)
- if _, err = fmt.Fprintf(w, "tree %s\n", b.TreeHash.String()); err != nil {
+ if _, err = fmt.Fprintf(w, "tree %s\n", c.TreeHash.String()); err != nil {
return err
}
- for _, parent := range b.ParentHashes {
+ for _, parent := range c.ParentHashes {
if _, err = fmt.Fprintf(w, "parent %s\n", parent.String()); err != nil {
return err
}
@@ -275,7 +275,7 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
return err
}
- if err = b.Author.Encode(w); err != nil {
+ if err = c.Author.Encode(w); err != nil {
return err
}
@@ -283,11 +283,11 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
return err
}
- if err = b.Committer.Encode(w); err != nil {
+ if err = c.Committer.Encode(w); err != nil {
return err
}
- if b.PGPSignature != "" && includeSig {
+ if c.PGPSignature != "" && includeSig {
if _, err = fmt.Fprint(w, "\n"+headerpgp+" "); err != nil {
return err
}
@@ -296,14 +296,14 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
// newline. Use join for this so it's clear that a newline should not be
// added after this section, as it will be added when the message is
// printed.
- signature := strings.TrimSuffix(b.PGPSignature, "\n")
+ signature := strings.TrimSuffix(c.PGPSignature, "\n")
lines := strings.Split(signature, "\n")
if _, err = fmt.Fprint(w, strings.Join(lines, "\n ")); err != nil {
return err
}
}
- if _, err = fmt.Fprintf(w, "\n\n%s", b.Message); err != nil {
+ if _, err = fmt.Fprintf(w, "\n\n%s", c.Message); err != nil {
return err
}
diff --git a/plumbing/object/commit_stats_test.go b/plumbing/object/commit_stats_test.go
index bce2953..4078ce8 100644
--- a/plumbing/object/commit_stats_test.go
+++ b/plumbing/object/commit_stats_test.go
@@ -11,8 +11,9 @@ import (
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/util"
+
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type CommitStatsSuite struct {
diff --git a/plumbing/object/commit_walker_bfs_filtered.go b/plumbing/object/commit_walker_bfs_filtered.go
index e87c3db..9d51813 100644
--- a/plumbing/object/commit_walker_bfs_filtered.go
+++ b/plumbing/object/commit_walker_bfs_filtered.go
@@ -173,4 +173,3 @@ func (w *filterCommitIter) addToQueue(
return nil
}
-
diff --git a/plumbing/object/commit_walker_path.go b/plumbing/object/commit_walker_path.go
index af6f745..aa0ca15 100644
--- a/plumbing/object/commit_walker_path.go
+++ b/plumbing/object/commit_walker_path.go
@@ -4,7 +4,6 @@ import (
"io"
"github.com/go-git/go-git/v5/plumbing"
-
"github.com/go-git/go-git/v5/plumbing/storer"
)
@@ -29,7 +28,7 @@ func NewCommitPathIterFromIter(pathFilter func(string) bool, commitIter CommitIt
return iterator
}
-// this function is kept for compatibilty, can be replaced with NewCommitPathIterFromIter
+// NewCommitFileIterFromIter is kept for compatibility, can be replaced with NewCommitPathIterFromIter
func NewCommitFileIterFromIter(fileName string, commitIter CommitIter, checkParent bool) CommitIter {
return NewCommitPathIterFromIter(
func(path string) bool {
diff --git a/plumbing/object/commitgraph/commitnode_test.go b/plumbing/object/commitgraph/commitnode_test.go
index 38d3bce..6c9a643 100644
--- a/plumbing/object/commitgraph/commitnode_test.go
+++ b/plumbing/object/commitgraph/commitnode_test.go
@@ -4,13 +4,14 @@ import (
"path"
"testing"
- . "gopkg.in/check.v1"
- fixtures "github.com/go-git/go-git-fixtures/v4"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/plumbing/format/commitgraph"
"github.com/go-git/go-git/v5/plumbing/format/packfile"
"github.com/go-git/go-git/v5/storage/filesystem"
+
+ fixtures "github.com/go-git/go-git-fixtures/v4"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/object/commitgraph/commitnode_walker_ctime.go b/plumbing/object/commitgraph/commitnode_walker_ctime.go
index f2ed663..281f10b 100644
--- a/plumbing/object/commitgraph/commitnode_walker_ctime.go
+++ b/plumbing/object/commitgraph/commitnode_walker_ctime.go
@@ -3,10 +3,10 @@ package commitgraph
import (
"io"
- "github.com/emirpasic/gods/trees/binaryheap"
-
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/storer"
+
+ "github.com/emirpasic/gods/trees/binaryheap"
)
type commitNodeIteratorByCTime struct {
diff --git a/plumbing/object/file_test.go b/plumbing/object/file_test.go
index 4dfd950..ada6654 100644
--- a/plumbing/object/file_test.go
+++ b/plumbing/object/file_test.go
@@ -9,8 +9,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/storer"
"github.com/go-git/go-git/v5/storage/filesystem"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type FileSuite struct {
diff --git a/plumbing/object/patch.go b/plumbing/object/patch.go
index 1135a40..9b5f438 100644
--- a/plumbing/object/patch.go
+++ b/plumbing/object/patch.go
@@ -121,12 +121,12 @@ type Patch struct {
filePatches []fdiff.FilePatch
}
-func (t *Patch) FilePatches() []fdiff.FilePatch {
- return t.filePatches
+func (p *Patch) FilePatches() []fdiff.FilePatch {
+ return p.filePatches
}
-func (t *Patch) Message() string {
- return t.message
+func (p *Patch) Message() string {
+ return p.message
}
func (p *Patch) Encode(w io.Writer) error {
@@ -198,12 +198,12 @@ func (tf *textFilePatch) Files() (from fdiff.File, to fdiff.File) {
return
}
-func (t *textFilePatch) IsBinary() bool {
- return len(t.chunks) == 0
+func (tf *textFilePatch) IsBinary() bool {
+ return len(tf.chunks) == 0
}
-func (t *textFilePatch) Chunks() []fdiff.Chunk {
- return t.chunks
+func (tf *textFilePatch) Chunks() []fdiff.Chunk {
+ return tf.chunks
}
// textChunk is an implementation of fdiff.Chunk interface
diff --git a/plumbing/object/patch_test.go b/plumbing/object/patch_test.go
index d4b6cd6..2cff795 100644
--- a/plumbing/object/patch_test.go
+++ b/plumbing/object/patch_test.go
@@ -1,11 +1,12 @@
package object
import (
- . "gopkg.in/check.v1"
- fixtures "github.com/go-git/go-git-fixtures/v4"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
"github.com/go-git/go-git/v5/storage/filesystem"
+
+ fixtures "github.com/go-git/go-git-fixtures/v4"
+ . "gopkg.in/check.v1"
)
type PatchSuite struct {
diff --git a/plumbing/object/rename.go b/plumbing/object/rename.go
index 35af1d6..7fed72c 100644
--- a/plumbing/object/rename.go
+++ b/plumbing/object/rename.go
@@ -536,7 +536,7 @@ var errIndexFull = errors.New("index is full")
// between two files.
// To save space in memory, this index uses a space efficient encoding which
// will not exceed 1MiB per instance. The index starts out at a smaller size
-// (closer to 2KiB), but may grow as more distinct blocks withing the scanned
+// (closer to 2KiB), but may grow as more distinct blocks within the scanned
// file are discovered.
// see: https://github.com/eclipse/jgit/blob/master/org.eclipse.jgit/src/org/eclipse/jgit/diff/SimilarityIndex.java
type similarityIndex struct {
@@ -709,7 +709,7 @@ func (i *similarityIndex) common(dst *similarityIndex) uint64 {
}
func (i *similarityIndex) add(key int, cnt uint64) error {
- key = int(uint32(key)*0x9e370001 >> 1)
+ key = int(uint32(key) * 0x9e370001 >> 1)
j := i.slot(key)
for {
@@ -769,7 +769,7 @@ func (i *similarityIndex) slot(key int) int {
// We use 31 - hashBits because the upper bit was already forced
// to be 0 and we want the remaining high bits to be used as the
// table slot.
- return int(uint32(key) >> uint(31 - i.hashBits))
+ return int(uint32(key) >> uint(31-i.hashBits))
}
func shouldGrowAt(hashBits int) int {
diff --git a/plumbing/protocol/packp/ulreq.go b/plumbing/protocol/packp/ulreq.go
index 44db8e4..ddec06e 100644
--- a/plumbing/protocol/packp/ulreq.go
+++ b/plumbing/protocol/packp/ulreq.go
@@ -109,42 +109,42 @@ func NewUploadRequestFromCapabilities(adv *capability.List) *UploadRequest {
// - is a DepthReference is given capability.DeepenNot MUST be present
// - MUST contain only maximum of one of capability.Sideband and capability.Sideband64k
// - MUST contain only maximum of one of capability.MultiACK and capability.MultiACKDetailed
-func (r *UploadRequest) Validate() error {
- if len(r.Wants) == 0 {
+func (req *UploadRequest) Validate() error {
+ if len(req.Wants) == 0 {
return fmt.Errorf("want can't be empty")
}
- if err := r.validateRequiredCapabilities(); err != nil {
+ if err := req.validateRequiredCapabilities(); err != nil {
return err
}
- if err := r.validateConflictCapabilities(); err != nil {
+ if err := req.validateConflictCapabilities(); err != nil {
return err
}
return nil
}
-func (r *UploadRequest) validateRequiredCapabilities() error {
+func (req *UploadRequest) validateRequiredCapabilities() error {
msg := "missing capability %s"
- if len(r.Shallows) != 0 && !r.Capabilities.Supports(capability.Shallow) {
+ if len(req.Shallows) != 0 && !req.Capabilities.Supports(capability.Shallow) {
return fmt.Errorf(msg, capability.Shallow)
}
- switch r.Depth.(type) {
+ switch req.Depth.(type) {
case DepthCommits:
- if r.Depth != DepthCommits(0) {
- if !r.Capabilities.Supports(capability.Shallow) {
+ if req.Depth != DepthCommits(0) {
+ if !req.Capabilities.Supports(capability.Shallow) {
return fmt.Errorf(msg, capability.Shallow)
}
}
case DepthSince:
- if !r.Capabilities.Supports(capability.DeepenSince) {
+ if !req.Capabilities.Supports(capability.DeepenSince) {
return fmt.Errorf(msg, capability.DeepenSince)
}
case DepthReference:
- if !r.Capabilities.Supports(capability.DeepenNot) {
+ if !req.Capabilities.Supports(capability.DeepenNot) {
return fmt.Errorf(msg, capability.DeepenNot)
}
}
@@ -152,15 +152,15 @@ func (r *UploadRequest) validateRequiredCapabilities() error {
return nil
}
-func (r *UploadRequest) validateConflictCapabilities() error {
+func (req *UploadRequest) validateConflictCapabilities() error {
msg := "capabilities %s and %s are mutually exclusive"
- if r.Capabilities.Supports(capability.Sideband) &&
- r.Capabilities.Supports(capability.Sideband64k) {
+ if req.Capabilities.Supports(capability.Sideband) &&
+ req.Capabilities.Supports(capability.Sideband64k) {
return fmt.Errorf(msg, capability.Sideband, capability.Sideband64k)
}
- if r.Capabilities.Supports(capability.MultiACK) &&
- r.Capabilities.Supports(capability.MultiACKDetailed) {
+ if req.Capabilities.Supports(capability.MultiACK) &&
+ req.Capabilities.Supports(capability.MultiACKDetailed) {
return fmt.Errorf(msg, capability.MultiACK, capability.MultiACKDetailed)
}
diff --git a/plumbing/protocol/packp/ulreq_decode.go b/plumbing/protocol/packp/ulreq_decode.go
index 449b729..895a3bf 100644
--- a/plumbing/protocol/packp/ulreq_decode.go
+++ b/plumbing/protocol/packp/ulreq_decode.go
@@ -14,9 +14,9 @@ import (
// Decode reads the next upload-request form its input and
// stores it in the UploadRequest.
-func (u *UploadRequest) Decode(r io.Reader) error {
+func (req *UploadRequest) Decode(r io.Reader) error {
d := newUlReqDecoder(r)
- return d.Decode(u)
+ return d.Decode(req)
}
type ulReqDecoder struct {
diff --git a/plumbing/protocol/packp/ulreq_encode.go b/plumbing/protocol/packp/ulreq_encode.go
index 4863076..c451e23 100644
--- a/plumbing/protocol/packp/ulreq_encode.go
+++ b/plumbing/protocol/packp/ulreq_encode.go
@@ -15,9 +15,9 @@ import (
// All the payloads will end with a newline character. Wants and
// shallows are sorted alphabetically. A depth of 0 means no depth
// request is sent.
-func (u *UploadRequest) Encode(w io.Writer) error {
+func (req *UploadRequest) Encode(w io.Writer) error {
e := newUlReqEncoder(w)
- return e.Encode(u)
+ return e.Encode(req)
}
type ulReqEncoder struct {
diff --git a/plumbing/protocol/packp/updreq.go b/plumbing/protocol/packp/updreq.go
index b63b023..4d927d8 100644
--- a/plumbing/protocol/packp/updreq.go
+++ b/plumbing/protocol/packp/updreq.go
@@ -68,12 +68,12 @@ func NewReferenceUpdateRequestFromCapabilities(adv *capability.List) *ReferenceU
return r
}
-func (r *ReferenceUpdateRequest) validate() error {
- if len(r.Commands) == 0 {
+func (req *ReferenceUpdateRequest) validate() error {
+ if len(req.Commands) == 0 {
return ErrEmptyCommands
}
- for _, c := range r.Commands {
+ for _, c := range req.Commands {
if err := c.validate(); err != nil {
return err
}
diff --git a/plumbing/protocol/packp/updreq_encode.go b/plumbing/protocol/packp/updreq_encode.go
index 6a79653..2545e93 100644
--- a/plumbing/protocol/packp/updreq_encode.go
+++ b/plumbing/protocol/packp/updreq_encode.go
@@ -14,33 +14,33 @@ var (
)
// Encode writes the ReferenceUpdateRequest encoding to the stream.
-func (r *ReferenceUpdateRequest) Encode(w io.Writer) error {
- if err := r.validate(); err != nil {
+func (req *ReferenceUpdateRequest) Encode(w io.Writer) error {
+ if err := req.validate(); err != nil {
return err
}
e := pktline.NewEncoder(w)
- if err := r.encodeShallow(e, r.Shallow); err != nil {
+ if err := req.encodeShallow(e, req.Shallow); err != nil {
return err
}
- if err := r.encodeCommands(e, r.Commands, r.Capabilities); err != nil {
+ if err := req.encodeCommands(e, req.Commands, req.Capabilities); err != nil {
return err
}
- if r.Packfile != nil {
- if _, err := io.Copy(w, r.Packfile); err != nil {
+ if req.Packfile != nil {
+ if _, err := io.Copy(w, req.Packfile); err != nil {
return err
}
- return r.Packfile.Close()
+ return req.Packfile.Close()
}
return nil
}
-func (r *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
+func (req *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
h *plumbing.Hash) error {
if h == nil {
@@ -51,7 +51,7 @@ func (r *ReferenceUpdateRequest) encodeShallow(e *pktline.Encoder,
return e.Encodef("%s%s", shallow, objId)
}
-func (r *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder,
+func (req *ReferenceUpdateRequest) encodeCommands(e *pktline.Encoder,
cmds []*Command, cap *capability.List) error {
if err := e.Encodef("%s\x00%s",
diff --git a/plumbing/protocol/packp/uppackresp_test.go b/plumbing/protocol/packp/uppackresp_test.go
index 8950fa9..260dc57 100644
--- a/plumbing/protocol/packp/uppackresp_test.go
+++ b/plumbing/protocol/packp/uppackresp_test.go
@@ -4,10 +4,10 @@ import (
"bytes"
"io/ioutil"
+ "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git/v5/plumbing"
)
type UploadPackResponseSuite struct{}
diff --git a/plumbing/storer/object_test.go b/plumbing/storer/object_test.go
index 8dc3623..30424ff 100644
--- a/plumbing/storer/object_test.go
+++ b/plumbing/storer/object_test.go
@@ -4,8 +4,9 @@ import (
"fmt"
"testing"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/storer/reference_test.go b/plumbing/storer/reference_test.go
index 0660043..7a4d8b4 100644
--- a/plumbing/storer/reference_test.go
+++ b/plumbing/storer/reference_test.go
@@ -4,8 +4,9 @@ import (
"errors"
"io"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
type ReferenceSuite struct{}
diff --git a/plumbing/transport/file/receive_pack_test.go b/plumbing/transport/file/receive_pack_test.go
index 2ee4b86..686bdcc 100644
--- a/plumbing/transport/file/receive_pack_test.go
+++ b/plumbing/transport/file/receive_pack_test.go
@@ -5,8 +5,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport/test"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type ReceivePackSuite struct {
diff --git a/plumbing/transport/git/common_test.go b/plumbing/transport/git/common_test.go
index 551b50d..3391aaf 100644
--- a/plumbing/transport/git/common_test.go
+++ b/plumbing/transport/git/common_test.go
@@ -13,8 +13,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/transport/git/receive_pack_test.go b/plumbing/transport/git/receive_pack_test.go
index 1f730a4..b661d71 100644
--- a/plumbing/transport/git/receive_pack_test.go
+++ b/plumbing/transport/git/receive_pack_test.go
@@ -3,8 +3,8 @@ package git
import (
"github.com/go-git/go-git/v5/plumbing/transport/test"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type ReceivePackSuite struct {
diff --git a/plumbing/transport/git/upload_pack_test.go b/plumbing/transport/git/upload_pack_test.go
index bbfdf58..5200953 100644
--- a/plumbing/transport/git/upload_pack_test.go
+++ b/plumbing/transport/git/upload_pack_test.go
@@ -3,8 +3,8 @@ package git
import (
"github.com/go-git/go-git/v5/plumbing/transport/test"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type UploadPackSuite struct {
diff --git a/plumbing/transport/http/common_test.go b/plumbing/transport/http/common_test.go
index 5811139..4122e62 100644
--- a/plumbing/transport/http/common_test.go
+++ b/plumbing/transport/http/common_test.go
@@ -17,8 +17,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/transport/http/receive_pack_test.go b/plumbing/transport/http/receive_pack_test.go
index b977908..7e70986 100644
--- a/plumbing/transport/http/receive_pack_test.go
+++ b/plumbing/transport/http/receive_pack_test.go
@@ -3,8 +3,8 @@ package http
import (
"github.com/go-git/go-git/v5/plumbing/transport/test"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type ReceivePackSuite struct {
diff --git a/plumbing/transport/http/upload_pack_test.go b/plumbing/transport/http/upload_pack_test.go
index b34441d..6fae443 100644
--- a/plumbing/transport/http/upload_pack_test.go
+++ b/plumbing/transport/http/upload_pack_test.go
@@ -11,8 +11,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/plumbing/transport/test"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type UploadPackSuite struct {
diff --git a/plumbing/transport/server/receive_pack_test.go b/plumbing/transport/server/receive_pack_test.go
index 2c5b0ae..6c704bd 100644
--- a/plumbing/transport/server/receive_pack_test.go
+++ b/plumbing/transport/server/receive_pack_test.go
@@ -60,4 +60,5 @@ func (s *ReceivePackSuite) TestReceivePackWithNilPackfile(c *C) {
report, err := r.ReceivePack(context.Background(), req)
c.Assert(report, IsNil, comment)
+ c.Assert(err, NotNil, comment)
}
diff --git a/plumbing/transport/ssh/common_test.go b/plumbing/transport/ssh/common_test.go
index 22a8243..87c1148 100644
--- a/plumbing/transport/ssh/common_test.go
+++ b/plumbing/transport/ssh/common_test.go
@@ -3,12 +3,11 @@ package ssh
import (
"testing"
- "github.com/kevinburke/ssh_config"
+ "github.com/go-git/go-git/v5/plumbing/transport"
+ "github.com/kevinburke/ssh_config"
"golang.org/x/crypto/ssh"
-
. "gopkg.in/check.v1"
- "github.com/go-git/go-git/v5/plumbing/transport"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/plumbing/transport/test/upload_pack.go b/plumbing/transport/test/upload_pack.go
index ee7b067..3ee029d 100644
--- a/plumbing/transport/test/upload_pack.go
+++ b/plumbing/transport/test/upload_pack.go
@@ -13,11 +13,11 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/packfile"
"github.com/go-git/go-git/v5/plumbing/protocol/packp"
+ "github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/storage/memory"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
)
type UploadPackSuite struct {
diff --git a/prune_test.go b/prune_test.go
index bd5168d..8c726d0 100644
--- a/prune_test.go
+++ b/prune_test.go
@@ -9,8 +9,8 @@ import (
"github.com/go-git/go-git/v5/storage"
"github.com/go-git/go-git/v5/storage/filesystem"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type PruneSuite struct {
diff --git a/references_test.go b/references_test.go
index 7c26ce2..28d1bb9 100644
--- a/references_test.go
+++ b/references_test.go
@@ -8,8 +8,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type ReferencesSuite struct {
diff --git a/remote.go b/remote.go
index e642c57..2c5d806 100644
--- a/remote.go
+++ b/remote.go
@@ -218,9 +218,9 @@ func (r *Remote) newReferenceUpdateRequest(
if o.Progress != nil {
req.Progress = o.Progress
if ar.Capabilities.Supports(capability.Sideband64k) {
- req.Capabilities.Set(capability.Sideband64k)
+ _ = req.Capabilities.Set(capability.Sideband64k)
} else if ar.Capabilities.Supports(capability.Sideband) {
- req.Capabilities.Set(capability.Sideband)
+ _ = req.Capabilities.Set(capability.Sideband)
}
}
@@ -1037,11 +1037,13 @@ func (r *Remote) List(o *ListOptions) (rfs []*plumbing.Reference, err error) {
}
var resultRefs []*plumbing.Reference
- refs.ForEach(func(ref *plumbing.Reference) error {
+ err = refs.ForEach(func(ref *plumbing.Reference) error {
resultRefs = append(resultRefs, ref)
return nil
})
-
+ if err != nil {
+ return nil, err
+ }
return resultRefs, nil
}
diff --git a/repository.go b/repository.go
index 1f6de76..172029c 100644
--- a/repository.go
+++ b/repository.go
@@ -92,7 +92,7 @@ func Init(s storage.Storer, worktree billy.Filesystem) (*Repository, error) {
}
if worktree == nil {
- r.setIsBare(true)
+ _ = r.setIsBare(true)
return r, nil
}
@@ -408,7 +408,7 @@ func PlainCloneContext(ctx context.Context, path string, isBare bool, o *CloneOp
err = r.clone(ctx, o)
if err != nil && err != ErrRepositoryAlreadyExists {
if cleanup {
- cleanUpDir(path, cleanupParent)
+ _ = cleanUpDir(path, cleanupParent)
}
}
diff --git a/repository_test.go b/repository_test.go
index d1af7b6..bbed604 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -1875,6 +1875,7 @@ func (s *RepositorySuite) TestConfigScoped(c *C) {
err := r.clone(context.Background(), &CloneOptions{
URL: s.GetBasicLocalRepositoryURL(),
})
+ c.Assert(err, IsNil)
cfg, err := r.ConfigScoped(config.LocalScope)
c.Assert(err, IsNil)
diff --git a/storage/filesystem/config_test.go b/storage/filesystem/config_test.go
index fe84698..c092d14 100644
--- a/storage/filesystem/config_test.go
+++ b/storage/filesystem/config_test.go
@@ -4,12 +4,12 @@ import (
"io/ioutil"
"os"
+ "github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/storage/filesystem/dotgit"
- "github.com/go-git/go-billy/v5/osfs"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type ConfigSuite struct {
diff --git a/storage/filesystem/dotgit/writers_test.go b/storage/filesystem/dotgit/writers_test.go
index 246d310..7147aec 100644
--- a/storage/filesystem/dotgit/writers_test.go
+++ b/storage/filesystem/dotgit/writers_test.go
@@ -13,8 +13,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/packfile"
"github.com/go-git/go-billy/v5/osfs"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
func (s *SuiteDotGit) TestNewObjectPack(c *C) {
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index fdf8fcf..a8e5669 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -195,10 +195,10 @@ func (o *ObjectStorage) DeleteOldObjectPackAndIndex(plumbing.Hash, time.Time) er
var errNotSupported = fmt.Errorf("Not supported")
-func (s *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) {
+func (o *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) {
return time.Time{}, errNotSupported
}
-func (s *ObjectStorage) DeleteLooseObject(plumbing.Hash) error {
+func (o *ObjectStorage) DeleteLooseObject(plumbing.Hash) error {
return errNotSupported
}
diff --git a/storage/transactional/config_test.go b/storage/transactional/config_test.go
index ec7ae89..1f3a572 100644
--- a/storage/transactional/config_test.go
+++ b/storage/transactional/config_test.go
@@ -1,9 +1,10 @@
package transactional
import (
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/storage/memory"
+
+ . "gopkg.in/check.v1"
)
var _ = Suite(&ConfigSuite{})
diff --git a/storage/transactional/index_test.go b/storage/transactional/index_test.go
index 88fa1f5..0028c0e 100644
--- a/storage/transactional/index_test.go
+++ b/storage/transactional/index_test.go
@@ -1,9 +1,10 @@
package transactional
import (
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing/format/index"
"github.com/go-git/go-git/v5/storage/memory"
+
+ . "gopkg.in/check.v1"
)
var _ = Suite(&IndexSuite{})
diff --git a/storage/transactional/object_test.go b/storage/transactional/object_test.go
index e634409..df277c4 100644
--- a/storage/transactional/object_test.go
+++ b/storage/transactional/object_test.go
@@ -1,9 +1,10 @@
package transactional
import (
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
+
+ . "gopkg.in/check.v1"
)
var _ = Suite(&ObjectSuite{})
diff --git a/storage/transactional/reference_test.go b/storage/transactional/reference_test.go
index a6bd1ce..05a4fcf 100644
--- a/storage/transactional/reference_test.go
+++ b/storage/transactional/reference_test.go
@@ -1,9 +1,10 @@
package transactional
import (
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
+
+ . "gopkg.in/check.v1"
)
var _ = Suite(&ReferenceSuite{})
diff --git a/storage/transactional/shallow_test.go b/storage/transactional/shallow_test.go
index 1209fe6..15d423c 100644
--- a/storage/transactional/shallow_test.go
+++ b/storage/transactional/shallow_test.go
@@ -1,9 +1,10 @@
package transactional
import (
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
+
+ . "gopkg.in/check.v1"
)
var _ = Suite(&ShallowSuite{})
diff --git a/submodule_test.go b/submodule_test.go
index 3d81965..418b3ee 100644
--- a/submodule_test.go
+++ b/submodule_test.go
@@ -9,8 +9,8 @@ import (
"github.com/go-git/go-git/v5/plumbing"
+ fixtures "github.com/go-git/go-git-fixtures/v4"
. "gopkg.in/check.v1"
- "github.com/go-git/go-git-fixtures/v4"
)
type SubmoduleSuite struct {
diff --git a/utils/binary/read_test.go b/utils/binary/read_test.go
index 3749258..bcd9dee 100644
--- a/utils/binary/read_test.go
+++ b/utils/binary/read_test.go
@@ -6,8 +6,9 @@ import (
"encoding/binary"
"testing"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
+
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/utils/diff/diff.go b/utils/diff/diff.go
index 6142ed0..7005494 100644
--- a/utils/diff/diff.go
+++ b/utils/diff/diff.go
@@ -29,7 +29,7 @@ func Do(src, dst string) (diffs []diffmatchpatch.Diff) {
// a bulk delete+insert and the half-baked suboptimal result is returned at once.
// The underlying algorithm is Meyers, its complexity is O(N*d) where N is
// min(lines(src), lines(dst)) and d is the size of the diff.
-func DoWithTimeout (src, dst string, timeout time.Duration) (diffs []diffmatchpatch.Diff) {
+func DoWithTimeout(src, dst string, timeout time.Duration) (diffs []diffmatchpatch.Diff) {
dmp := diffmatchpatch.New()
dmp.DiffTimeout = timeout
wSrc, wDst, warray := dmp.DiffLinesToRunes(src, dst)
diff --git a/utils/merkletrie/filesystem/node.go b/utils/merkletrie/filesystem/node.go
index 165bd42..2fc3d7a 100644
--- a/utils/merkletrie/filesystem/node.go
+++ b/utils/merkletrie/filesystem/node.go
@@ -91,8 +91,7 @@ func (n *node) calculateChildren() error {
if os.IsNotExist(err) {
return nil
}
-
- return nil
+ return err
}
for _, file := range files {
diff --git a/utils/merkletrie/filesystem/node_test.go b/utils/merkletrie/filesystem/node_test.go
index 0f6ebe0..159e63d 100644
--- a/utils/merkletrie/filesystem/node_test.go
+++ b/utils/merkletrie/filesystem/node_test.go
@@ -7,12 +7,13 @@ import (
"path"
"testing"
- "github.com/go-git/go-billy/v5"
- "github.com/go-git/go-billy/v5/memfs"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/utils/merkletrie"
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
+
+ "github.com/go-git/go-billy/v5"
+ "github.com/go-git/go-billy/v5/memfs"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/utils/merkletrie/index/node_test.go b/utils/merkletrie/index/node_test.go
index 4fa6c63..cc5600d 100644
--- a/utils/merkletrie/index/node_test.go
+++ b/utils/merkletrie/index/node_test.go
@@ -5,11 +5,12 @@ import (
"path/filepath"
"testing"
- . "gopkg.in/check.v1"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/format/index"
"github.com/go-git/go-git/v5/utils/merkletrie"
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
+
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/worktree.go b/worktree.go
index d272373..62ad03b 100644
--- a/worktree.go
+++ b/worktree.go
@@ -93,7 +93,7 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error {
head, err := w.r.Head()
if err == nil {
- headAheadOfRef,err := isFastForward(w.r.Storer, ref.Hash(), head.Hash())
+ headAheadOfRef, err := isFastForward(w.r.Storer, ref.Hash(), head.Hash())
if err != nil {
return err
}
@@ -102,7 +102,6 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error {
return NoErrAlreadyUpToDate
}
-
ff, err := isFastForward(w.r.Storer, head.Hash(), ref.Hash())
if err != nil {
return err
diff --git a/worktree_commit.go b/worktree_commit.go
index 63eb2e8..167f2e0 100644
--- a/worktree_commit.go
+++ b/worktree_commit.go
@@ -6,7 +6,6 @@ import (
"sort"
"strings"
- "golang.org/x/crypto/openpgp"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/filemode"
"github.com/go-git/go-git/v5/plumbing/format/index"
@@ -14,6 +13,7 @@ import (
"github.com/go-git/go-git/v5/storage"
"github.com/go-git/go-billy/v5"
+ "golang.org/x/crypto/openpgp"
)
// Commit stores the current contents of the index in a new commit along with