Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ func (b *blame) fillRevs() error {
var err error

b.revs, err = references(b.fRev, b.path)
if err != nil {
return err
}
return nil
return err
}

// build graph of a file from its revision history
Expand Down Expand Up @@ -244,7 +241,7 @@ func (b *blame) GoString() string {

lines := strings.Split(contents, "\n")
// max line number length
mlnl := len(fmt.Sprintf("%s", strconv.Itoa(len(lines))))
mlnl := len(strconv.Itoa(len(lines)))
// max author length
mal := b.maxAuthorLength()
format := fmt.Sprintf("%%s (%%-%ds %%%dd) %%s\n",
Expand Down
2 changes: 1 addition & 1 deletion common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *BaseSuite) SetUpSuite(c *C) {
s.Suite.SetUpSuite(c)
s.buildBasicRepository(c)

s.cache = make(map[string]*Repository, 0)
s.cache = make(map[string]*Repository)
}

func (s *BaseSuite) TearDownSuite(c *C) {
Expand Down
11 changes: 3 additions & 8 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ type Config struct {
// NewConfig returns a new empty Config.
func NewConfig() *Config {
return &Config{
Remotes: make(map[string]*RemoteConfig, 0),
Submodules: make(map[string]*Submodule, 0),
Remotes: make(map[string]*RemoteConfig),
Submodules: make(map[string]*Submodule),
Raw: format.New(),
}
}
Expand Down Expand Up @@ -290,13 +290,8 @@ func (c *RemoteConfig) unmarshal(s *format.Subsection) error {
fetch = append(fetch, rs)
}

var urls []string
for _, f := range c.raw.Options.GetAll(urlKey) {
urls = append(urls, f)
}

c.Name = c.raw.Name
c.URLs = urls
c.URLs = append([]string(nil), c.raw.Options.GetAll(urlKey)...)
c.Fetch = fetch

return nil
Expand Down
2 changes: 1 addition & 1 deletion config/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Modules struct {
// NewModules returns a new empty Modules
func NewModules() *Modules {
return &Modules{
Submodules: make(map[string]*Submodule, 0),
Submodules: make(map[string]*Submodule),
raw: format.New(),
}
}
Expand Down
14 changes: 3 additions & 11 deletions config/refspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,12 @@ func (s RefSpec) Validate() error {

// IsForceUpdate returns if update is allowed in non fast-forward merges.
func (s RefSpec) IsForceUpdate() bool {
if s[0] == refSpecForce[0] {
return true
}

return false
return s[0] == refSpecForce[0]
}

// IsDelete returns true if the refspec indicates a delete (empty src).
func (s RefSpec) IsDelete() bool {
if s[0] == refSpecSeparator[0] {
return true
}

return false
return s[0] == refSpecSeparator[0]
}

// Src return the src side.
Expand All @@ -87,7 +79,7 @@ func (s RefSpec) Match(n plumbing.ReferenceName) bool {

// IsWildcard returns true if the RefSpec contains a wildcard.
func (s RefSpec) IsWildcard() bool {
return strings.Index(string(s), refSpecWildcard) != -1
return strings.Contains(string(s), refSpecWildcard)
}

func (s RefSpec) matchExact(n plumbing.ReferenceName) bool {
Expand Down
8 changes: 2 additions & 6 deletions plumbing/format/config/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,13 @@ func (e *Encoder) encodeSubsection(sectionName string, s *Subsection) error {
return err
}

if err := e.encodeOptions(s.Options); err != nil {
return err
}

return nil
return e.encodeOptions(s.Options)
}

func (e *Encoder) encodeOptions(opts Options) error {
for _, o := range opts {
pattern := "\t%s = %s\n"
if strings.Index(o.Value, "\\") != -1 {
if strings.Contains(o.Value, "\\") {
pattern = "\t%s = %q\n"
}

Expand Down
11 changes: 4 additions & 7 deletions plumbing/format/index/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@ func (d *Decoder) padEntry(idx *Index, e *Entry, read int) error {

entrySize := read + len(e.Name)
padLen := 8 - entrySize%8
if _, err := io.CopyN(ioutil.Discard, d.r, int64(padLen)); err != nil {
return err
}

return nil
_, err := io.CopyN(ioutil.Discard, d.r, int64(padLen))
return err
}

func (d *Decoder) readExtensions(idx *Index) error {
Expand Down Expand Up @@ -288,7 +285,7 @@ func (d *Decoder) readChecksum(expected []byte, alreadyRead [4]byte) error {
return err
}

if bytes.Compare(h[:], expected) != 0 {
if !bytes.Equal(h[:], expected) {
return ErrInvalidChecksum
}

Expand Down Expand Up @@ -407,7 +404,7 @@ func (d *resolveUndoDecoder) Decode(ru *ResolveUndo) error {

func (d *resolveUndoDecoder) readEntry() (*ResolveUndoEntry, error) {
e := &ResolveUndoEntry{
Stages: make(map[Stage]plumbing.Hash, 0),
Stages: make(map[Stage]plumbing.Hash),
}

path, err := binary.ReadUntil(d.r, '\x00')
Expand Down
6 changes: 1 addition & 5 deletions plumbing/format/objfile/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,5 @@ func (r *Reader) Hash() plumbing.Hash {
// Close releases any resources consumed by the Reader. Calling Close does not
// close the wrapped io.Reader originally passed to NewReader.
func (r *Reader) Close() error {
if err := r.zlib.Close(); err != nil {
return err
}

return nil
return r.zlib.Close()
}
2 changes: 1 addition & 1 deletion plumbing/format/packfile/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func NewDecoderForType(s *Scanner, o storer.EncodedObjectStorer,
o: o,

idx: NewIndex(0),
offsetToType: make(map[int64]plumbing.ObjectType, 0),
offsetToType: make(map[int64]plumbing.ObjectType),
decoderType: t,
}, nil
}
Expand Down
4 changes: 1 addition & 3 deletions plumbing/format/packfile/delta_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,10 @@ var len8tab = [256]uint8{
}

func hashBlock(raw []byte, ptr int) int {
var hash uint32

// The first 4 steps collapse out into a 4 byte big-endian decode,
// with a larger right shift as we combined shift lefts together.
//
hash = ((uint32(raw[ptr]) & 0xff) << 24) |
hash := ((uint32(raw[ptr]) & 0xff) << 24) |
((uint32(raw[ptr+1]) & 0xff) << 16) |
((uint32(raw[ptr+2]) & 0xff) << 8) |
(uint32(raw[ptr+3]) & 0xff)
Expand Down
6 changes: 1 addition & 5 deletions plumbing/format/packfile/object_pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ func (o *ObjectToPack) Size() int64 {
}

func (o *ObjectToPack) IsDelta() bool {
if o.Base != nil {
return true
}

return false
return o.Base != nil
}

func (o *ObjectToPack) SetDelta(base *ObjectToPack, delta plumbing.EncodedObject) {
Expand Down
7 changes: 2 additions & 5 deletions plumbing/format/packfile/patch_delta.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ func ApplyDelta(target, base plumbing.EncodedObject, delta []byte) error {

target.SetSize(int64(len(dst)))

if _, err := w.Write(dst); err != nil {
return err
}

return nil
_, err = w.Write(dst)
return err
}

var (
Expand Down
12 changes: 3 additions & 9 deletions plumbing/format/pktline/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,15 @@ func (e *Encoder) encodeLine(p []byte) error {
}

if bytes.Equal(p, Flush) {
if err := e.Flush(); err != nil {
return err
}
return nil
return e.Flush()
}

n := len(p) + 4
if _, err := e.w.Write(asciiHex16(n)); err != nil {
return err
}
if _, err := e.w.Write(p); err != nil {
return err
}

return nil
_, err := e.w.Write(p)
return err
}

// Returns the hexadecimal ascii representation of the 16 less
Expand Down
2 changes: 1 addition & 1 deletion plumbing/protocol/packp/advrefs_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func encodeRefs(e *advRefsEncoder) encoderStateFn {
continue
}

hash, _ := e.data.References[r]
hash := e.data.References[r]
if e.err = e.pe.Encodef("%s %s\n", hash.String(), r); e.err != nil {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion plumbing/protocol/packp/shallowupd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r *ShallowUpdate) Decode(reader io.Reader) error {
err = r.decodeShallowLine(line)
case bytes.HasPrefix(line, unshallow):
err = r.decodeUnshallowLine(line)
case bytes.Compare(line, pktline.Flush) == 0:
case bytes.Equal(line, pktline.Flush):
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions plumbing/protocol/packp/srvresp.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (r *ServerResponse) stopReading(reader *bufio.Reader) (bool, error) {
func (r *ServerResponse) isValidCommand(b []byte) bool {
commands := [][]byte{ack, nak}
for _, c := range commands {
if bytes.Compare(b, c) == 0 {
if bytes.Equal(b, c) {
return true
}
}
Expand All @@ -90,11 +90,11 @@ func (r *ServerResponse) decodeLine(line []byte) error {
return fmt.Errorf("unexpected flush")
}

if bytes.Compare(line[0:3], ack) == 0 {
if bytes.Equal(line[0:3], ack) {
return r.decodeACKLine(line)
}

if bytes.Compare(line[0:3], nak) == 0 {
if bytes.Equal(line[0:3], nak) {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions plumbing/protocol/packp/ulreq_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (e *ulReqEncoder) encodeFirstWant() stateFn {
func (e *ulReqEncoder) encodeAditionalWants() stateFn {
last := e.data.Wants[0]
for _, w := range e.data.Wants[1:] {
if bytes.Compare(last[:], w[:]) == 0 {
if bytes.Equal(last[:], w[:]) {
continue
}

Expand All @@ -90,7 +90,7 @@ func (e *ulReqEncoder) encodeShallows() stateFn {

var last plumbing.Hash
for _, s := range e.data.Shallows {
if bytes.Compare(last[:], s[:]) == 0 {
if bytes.Equal(last[:], s[:]) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion plumbing/protocol/packp/uppackreq.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (u *UploadHaves) Encode(w io.Writer, flush bool) error {

var last plumbing.Hash
for _, have := range u.Haves {
if bytes.Compare(last[:], have[:]) == 0 {
if bytes.Equal(last[:], have[:]) {
continue
}

Expand Down
4 changes: 2 additions & 2 deletions plumbing/protocol/packp/uppackresp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *UploadPackResponseSuite) TestEncodeNAK(c *C) {
c.Assert(res.Encode(b), IsNil)

expected := "0008NAK\n[PACK]"
c.Assert(string(b.Bytes()), Equals, expected)
c.Assert(b.String(), Equals, expected)
}

func (s *UploadPackResponseSuite) TestEncodeDepth(c *C) {
Expand All @@ -107,7 +107,7 @@ func (s *UploadPackResponseSuite) TestEncodeDepth(c *C) {
c.Assert(res.Encode(b), IsNil)

expected := "00000008NAK\nPACK"
c.Assert(string(b.Bytes()), Equals, expected)
c.Assert(b.String(), Equals, expected)
}

func (s *UploadPackResponseSuite) TestEncodeMultiACK(c *C) {
Expand Down
24 changes: 4 additions & 20 deletions plumbing/storer/reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ func (s *ReferenceSuite) TestReferenceFilteredIterNext(c *C) {
}

i := NewReferenceFilteredIter(func(r *plumbing.Reference) bool {
if r.Name() == "bar" {
return true
}

return false
return r.Name() == "bar"
}, NewReferenceSliceIter(slice))
foo, err := i.Next()
c.Assert(err, IsNil)
Expand All @@ -120,11 +116,7 @@ func (s *ReferenceSuite) TestReferenceFilteredIterForEach(c *C) {
}

i := NewReferenceFilteredIter(func(r *plumbing.Reference) bool {
if r.Name() == "bar" {
return true
}

return false
return r.Name() == "bar"
}, NewReferenceSliceIter(slice))
var count int
i.ForEach(func(r *plumbing.Reference) error {
Expand All @@ -143,11 +135,7 @@ func (s *ReferenceSuite) TestReferenceFilteredIterError(c *C) {
}

i := NewReferenceFilteredIter(func(r *plumbing.Reference) bool {
if r.Name() == "bar" {
return true
}

return false
return r.Name() == "bar"
}, NewReferenceSliceIter(slice))
var count int
exampleErr := errors.New("SOME ERROR")
Expand All @@ -172,11 +160,7 @@ func (s *ReferenceSuite) TestReferenceFilteredIterForEachStop(c *C) {
}

i := NewReferenceFilteredIter(func(r *plumbing.Reference) bool {
if r.Name() == "bar" {
return true
}

return false
return r.Name() == "bar"
}, NewReferenceSliceIter(slice))

var count int
Expand Down
2 changes: 1 addition & 1 deletion references.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
// to fix this).
func references(c *object.Commit, path string) ([]*object.Commit, error) {
var result []*object.Commit
seen := make(map[plumbing.Hash]struct{}, 0)
seen := make(map[plumbing.Hash]struct{})
if err := walkGraph(&result, &seen, c, path); err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func getHaves(
}

for _, ref := range localRefs {
if haves[ref.Hash()] == true {
if haves[ref.Hash()] {
continue
}

Expand Down Expand Up @@ -618,7 +618,7 @@ func calculateRefs(
return nil, err
}

refs := make(memory.ReferenceStorage, 0)
refs := make(memory.ReferenceStorage)
return refs, iter.ForEach(func(ref *plumbing.Reference) error {
if !config.MatchAny(spec, ref.Name()) {
return nil
Expand Down
Loading