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
2 changes: 1 addition & 1 deletion clients/ssh/git_upload_pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (f *fetchSession) Close() (err error) {

func (s *GitUploadPackService) getCommand() string {
directory := s.endpoint.Path
directory = directory[1:len(directory)]
directory = directory[1:]

return fmt.Sprintf("git-upload-pack '%s'", directory)
}
4 changes: 2 additions & 2 deletions commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) {
ts, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05-07:00")
c.Assert(err, IsNil)
commits := []*Commit{
&Commit{
{
Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
Message: "Message\n\nFoo\nBar\nWith trailing blank lines\n\n",
tree: core.NewHash("f000000000000000000000000000000000000001"),
parents: []core.Hash{core.NewHash("f000000000000000000000000000000000000002")},
},
&Commit{
{
Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
Message: "Message\n\nFoo\nBar\nWith no trailing blank lines",
Expand Down
6 changes: 3 additions & 3 deletions config/refspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s RefSpec) IsValid() bool {
}

ws := strings.Count(spec[0:sep], refSpecWildcard)
wd := strings.Count(spec[sep+1:len(spec)], refSpecWildcard)
wd := strings.Count(spec[sep+1:], refSpecWildcard)
return ws == wd && ws < 2 && wd < 2
}

Expand Down Expand Up @@ -95,7 +95,7 @@ func (s RefSpec) matchGlob(n core.ReferenceName) bool {
func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName {
spec := string(s)
start := strings.Index(spec, refSpecSeparator) + 1
dst := spec[start:len(spec)]
dst := spec[start:]
src := s.Src()

if !s.IsWildcard() {
Expand All @@ -107,7 +107,7 @@ func (s RefSpec) Dst(n core.ReferenceName) core.ReferenceName {
wd := strings.Index(dst, refSpecWildcard)
match := name[ws : len(name)-(len(src)-(ws+1))]

return core.ReferenceName(dst[0:wd] + match + dst[wd+1:len(dst)])
return core.ReferenceName(dst[0:wd] + match + dst[wd+1:])
}

func (s RefSpec) String() string {
Expand Down
2 changes: 1 addition & 1 deletion core/memory.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core
package core

import (
"bytes"
Expand Down
6 changes: 3 additions & 3 deletions cshared/auth_method_cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ func c_ParseAuthorizedKey(in []byte) (uint64, *C.char, *C.char, *C.char, int, in
pkey, comment, options, rest, err := ssh.ParseAuthorizedKey(in)
if err != nil {
return IH, nil, nil, nil, 0, ErrorCodeInternal,
C.CString(err.Error())
C.CString(err.Error())
}
pkey_handle := RegisterObject(&pkey)
mopt := strings.Join(options, "\xff")
return uint64(pkey_handle), C.CString(comment), C.CString(mopt),
C.CString(string(rest)), len(rest), ErrorCodeSuccess, nil
C.CString(string(rest)), len(rest), ErrorCodeSuccess, nil
}

//export c_ssh_Password_New
Expand Down Expand Up @@ -189,4 +189,4 @@ func c_ssh_PublicKeys_set_Signer(p uint64, v uint64) {
return
}
obj.(*gssh.PublicKeys).Signer = *signer.(*ssh.Signer)
}
}
2 changes: 0 additions & 2 deletions cshared/blame_cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func c_Blame_get_Rev(b uint64) *C.char {
return CBytes(blame.Rev[:])
}


//export c_Blame_get_Lines_len
func c_Blame_get_Lines_len(b uint64) int {
obj, ok := GetObject(Handle(b))
Expand All @@ -48,4 +47,3 @@ func c_Blame_get_Lines_item(b uint64, i int) {
line := blame.Lines[i]
_ = line
}

2 changes: 1 addition & 1 deletion cshared/file_cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func c_File_Read(b uint64) (int, *C.char) {
if err != nil {
return ErrorCodeInternal, C.CString(err.Error())
}
data, err := ioutil.ReadAll(reader)
data, err := ioutil.ReadAll(reader)
reader.Close()
if err != nil {
return ErrorCodeInternal, C.CString(err.Error())
Expand Down
33 changes: 17 additions & 16 deletions cshared/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ import (
"C"
"fmt"
"math"
"sync"
"reflect"
"sync"
)

type Handle uint64

const (
ErrorCodeSuccess = iota
ErrorCodeSuccess = iota
ErrorCodeNotFound = -iota
ErrorCodeInternal = -iota
)

const MessageNotFound string = "object not found"
const InvalidHandle Handle = 0
const IH uint64 = uint64(InvalidHandle)

var counter Handle = InvalidHandle
var opMutex sync.Mutex
var registryHandle2Obj map[Handle]interface{} = map[Handle]interface{}{}
Expand All @@ -43,7 +44,7 @@ func RegisterObject(obj interface{}) Handle {
defer opMutex.Unlock()
handles, ok := registryObj2Handle[data_ptr]
if ok {
for _, h := range(handles) {
for _, h := range handles {
other, ok := registryHandle2Obj[h]
if !ok {
panic("Inconsistent internal object mapping state (1)")
Expand All @@ -56,7 +57,7 @@ func RegisterObject(obj interface{}) Handle {
}
}
}
handle := getNewHandle()
handle := getNewHandle()
registryHandle2Obj[handle] = obj
registryObj2Handle[data_ptr] = append(registryObj2Handle[data_ptr], handle)
if trace {
Expand All @@ -67,7 +68,7 @@ func RegisterObject(obj interface{}) Handle {

func UnregisterObject(handle Handle) int {
if trace {
fmt.Printf("UnregisterObject %d\n", handle)
fmt.Printf("UnregisterObject %d\n", handle)
}
if handle == InvalidHandle {
return ErrorCodeNotFound
Expand All @@ -83,23 +84,23 @@ func UnregisterObject(handle Handle) int {
other_handles, ok := registryObj2Handle[data_ptr]
if !ok {
panic(fmt.Sprintf("Inconsistent internal object mapping state (2): %d",
handle))
handle))
}
hi := -1
for i, h := range(other_handles) {
for i, h := range other_handles {
if h == handle {
hi = i
break
}
}
if hi < 0 {
panic(fmt.Sprintf("Inconsistent internal object mapping state (3): %d",
handle))
handle))
}
if len(other_handles) == 1 {
delete(registryObj2Handle, data_ptr)
} else {
registryObj2Handle[data_ptr] = append(other_handles[:hi], other_handles[hi + 1:]...)
registryObj2Handle[data_ptr] = append(other_handles[:hi], other_handles[hi+1:]...)
}
if trace {
c_dump_objects()
Expand All @@ -125,7 +126,7 @@ func GetHandle(obj interface{}) (Handle, bool) {
if !ok {
return InvalidHandle, false
}
for _, h := range(handles) {
for _, h := range handles {
candidate := registryHandle2Obj[h]
if candidate == obj {
return h, true
Expand All @@ -143,13 +144,13 @@ func CopyString(str string) string {
// https://github.com/golang/go/issues/14838
func CBytes(bytes []byte) *C.char {
ptr := C.malloc(C.size_t(len(bytes)))
copy((*[1<<30]byte)(ptr)[:], bytes)
copy((*[1 << 30]byte)(ptr)[:], bytes)
return (*C.char)(ptr)
}

func SafeIsNil(v reflect.Value) bool {
defer func() { recover() }()
return v.IsNil()
defer func() { recover() }()
return v.IsNil()
}

//export c_dispose
Expand All @@ -165,17 +166,17 @@ func c_objects_size() int {
//export c_dump_objects
func c_dump_objects() {
fmt.Printf("handles (%d):\n", len(registryHandle2Obj))
for h, obj := range(registryHandle2Obj) {
for h, obj := range registryHandle2Obj {
fmt.Printf("0x%x\t0x%x %v\n", h,
reflect.ValueOf(&obj).Elem().InterfaceData()[1], obj)
}
fmt.Println()
phs := 0
for _, h := range(registryObj2Handle) {
for _, h := range registryObj2Handle {
phs += len(h)
}
fmt.Printf("pointers (%d):\n", phs)
for ptr, h := range(registryObj2Handle) {
for ptr, h := range registryObj2Handle {
fmt.Printf("0x%x\t%v\n", ptr, h)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cshared/objects_cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func c_Blob_Read(b uint64) (int, *C.char) {
if err != nil {
return ErrorCodeInternal, C.CString(err.Error())
}
data, err := ioutil.ReadAll(reader)
data, err := ioutil.ReadAll(reader)
reader.Close()
if err != nil {
return ErrorCodeInternal, C.CString(err.Error())
Expand All @@ -106,4 +106,4 @@ func c_Blob_Type(c uint64) int8 {
}
blob := obj.(*git.Blob)
return int8(blob.Type())
}
}
2 changes: 1 addition & 1 deletion cshared/std_cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func c_std_map_get_str_str(m uint64, key string) *C.char {
return nil
}
if (val.Kind() == reflect.Slice || val.Kind() == reflect.Array) &&
val.Type().Elem().Kind() == reflect.Uint8 {
val.Type().Elem().Kind() == reflect.Uint8 {
arr := make([]byte, val.Len(), val.Len())
reflect.Copy(reflect.ValueOf(arr), val)
return CBytes(arr)
Expand Down
8 changes: 4 additions & 4 deletions cshared/tag_cshared.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package main
import (
"C"
"io"

"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/core"
)
Expand Down Expand Up @@ -37,7 +37,7 @@ func c_Tag_get_Tagger(t uint64) uint64 {
}

func c_Tag_get_Message(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
Expand All @@ -46,7 +46,7 @@ func c_Tag_get_Message(t uint64) *C.char {
}

func c_Tag_get_TargetType(t uint64) int8 {
obj, ok := GetObject(Handle(t))
obj, ok := GetObject(Handle(t))
if !ok {
return -1
}
Expand All @@ -55,7 +55,7 @@ func c_Tag_get_TargetType(t uint64) int8 {
}

func c_Tag_get_Target(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions formats/packp/pktline/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ func (s *SuiteEncoder) TestEncode(c *C) {

func (s *SuiteEncoder) TestEncodeErrPayloadTooLong(c *C) {
for i, input := range [...][][]byte{
[][]byte{
{
[]byte(strings.Repeat("a", pktline.MaxPayloadSize+1)),
},
[][]byte{
{
[]byte("hello world!"),
[]byte(strings.Repeat("a", pktline.MaxPayloadSize+1)),
},
[][]byte{
{
[]byte("hello world!"),
[]byte(strings.Repeat("a", pktline.MaxPayloadSize+1)),
[]byte("foo"),
Expand Down Expand Up @@ -174,14 +174,14 @@ func (s *SuiteEncoder) TestEncodeStrings(c *C) {

func (s *SuiteEncoder) TestEncodeStringErrPayloadTooLong(c *C) {
for i, input := range [...][]string{
[]string{
{
strings.Repeat("a", pktline.MaxPayloadSize+1),
},
[]string{
{
"hello world!",
strings.Repeat("a", pktline.MaxPayloadSize+1),
},
[]string{
{
"hello world!",
strings.Repeat("a", pktline.MaxPayloadSize+1),
"foo",
Expand Down
4 changes: 2 additions & 2 deletions tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ func (s *TagSuite) TestTagEncodeDecodeIdempotent(c *C) {
ts, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05-07:00")
c.Assert(err, IsNil)
tags := []*Tag{
&Tag{
{
Name: "foo",
Tagger: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
Message: "Message\n\nFoo\nBar\nBaz\n\n",
TargetType: core.BlobObject,
Target: core.NewHash("b029517f6300c2da0f4b651b8642506cd6aaf45d"),
},
&Tag{
{
Name: "foo",
Tagger: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
TargetType: core.BlobObject,
Expand Down
Loading