gofmt
This commit is contained in:
parent
9cd1d129bc
commit
e504c9c021
10
checkout.go
10
checkout.go
|
@ -5,8 +5,8 @@ package git
|
|||
*/
|
||||
import "C"
|
||||
import (
|
||||
"runtime"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type CheckoutStrategy uint
|
||||
|
@ -32,10 +32,10 @@ const (
|
|||
|
||||
type CheckoutOpts struct {
|
||||
Strategy CheckoutStrategy // Default will be a dry run
|
||||
DisableFilters bool // Don't apply filters like CRLF conversion
|
||||
DirMode os.FileMode // Default is 0755
|
||||
FileMode os.FileMode // Default is 0644 or 0755 as dictated by blob
|
||||
FileOpenFlags int // Default is O_CREAT | O_TRUNC | O_WRONLY
|
||||
DisableFilters bool // Don't apply filters like CRLF conversion
|
||||
DirMode os.FileMode // Default is 0755
|
||||
FileMode os.FileMode // Default is 0644 or 0755 as dictated by blob
|
||||
FileOpenFlags int // Default is O_CREAT | O_TRUNC | O_WRONLY
|
||||
}
|
||||
|
||||
// Convert the CheckoutOpts struct to the corresponding
|
||||
|
|
|
@ -36,14 +36,14 @@ const (
|
|||
)
|
||||
|
||||
type ConfigEntry struct {
|
||||
Name string
|
||||
Name string
|
||||
Value string
|
||||
Level ConfigLevel
|
||||
}
|
||||
|
||||
func newConfigEntryFromC(centry *C.git_config_entry) *ConfigEntry {
|
||||
return &ConfigEntry{
|
||||
Name: C.GoString(centry.name),
|
||||
Name: C.GoString(centry.name),
|
||||
Value: C.GoString(centry.value),
|
||||
Level: ConfigLevel(centry.level),
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ func (c *Config) AddFile(path string, level ConfigLevel, force bool) error {
|
|||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
|
||||
ret := C.git_config_add_file_ondisk(c.ptr, cpath, C.git_config_level_t(level), cbool(force))
|
||||
if ret < 0 {
|
||||
return MakeGitError(ret)
|
||||
|
@ -131,7 +130,6 @@ func (c *Config) LookupString(name string) (string, error) {
|
|||
return C.GoString(ptr), nil
|
||||
}
|
||||
|
||||
|
||||
func (c *Config) LookupBool(name string) (bool, error) {
|
||||
var out C.int
|
||||
cname := C.CString(name)
|
||||
|
@ -374,4 +372,3 @@ func (iter *ConfigIterator) Free() {
|
|||
runtime.SetFinalizer(iter, nil)
|
||||
C.free(unsafe.Pointer(iter.ptr))
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ func (o *Cred) HasUsername() bool {
|
|||
}
|
||||
|
||||
func (o *Cred) Type() CredType {
|
||||
return (CredType)(o.ptr.credtype)
|
||||
return CredType(o.ptr.credtype)
|
||||
}
|
||||
|
||||
func credFromC(ptr *C.git_cred) *Cred {
|
||||
|
|
16
object.go
16
object.go
|
@ -10,12 +10,12 @@ import "runtime"
|
|||
type ObjectType int
|
||||
|
||||
const (
|
||||
ObjectAny ObjectType = C.GIT_OBJ_ANY
|
||||
ObjectBad = C.GIT_OBJ_BAD
|
||||
ObjectCommit = C.GIT_OBJ_COMMIT
|
||||
ObjectTree = C.GIT_OBJ_TREE
|
||||
ObjectBlob = C.GIT_OBJ_BLOB
|
||||
ObjectTag = C.GIT_OBJ_TAG
|
||||
ObjectAny ObjectType = C.GIT_OBJ_ANY
|
||||
ObjectBad = C.GIT_OBJ_BAD
|
||||
ObjectCommit = C.GIT_OBJ_COMMIT
|
||||
ObjectTree = C.GIT_OBJ_TREE
|
||||
ObjectBlob = C.GIT_OBJ_BLOB
|
||||
ObjectTag = C.GIT_OBJ_TAG
|
||||
)
|
||||
|
||||
type Object interface {
|
||||
|
@ -28,8 +28,8 @@ type gitObject struct {
|
|||
ptr *C.git_object
|
||||
}
|
||||
|
||||
func (t ObjectType) String() (string) {
|
||||
switch (t) {
|
||||
func (t ObjectType) String() string {
|
||||
switch t {
|
||||
case ObjectAny:
|
||||
return "Any"
|
||||
case ObjectBad:
|
||||
|
|
12
odb.go
12
odb.go
|
@ -8,9 +8,9 @@ extern int _go_git_odb_foreach(git_odb *db, void *payload);
|
|||
*/
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type Odb struct {
|
||||
|
@ -63,9 +63,9 @@ func odbForEachCb(id *C.git_oid, payload unsafe.Pointer) int {
|
|||
select {
|
||||
case ch <- oid:
|
||||
case <-ch:
|
||||
return -1
|
||||
return -1
|
||||
}
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
|
||||
func (v *Odb) forEachWrap(ch chan *Oid) {
|
||||
|
@ -88,7 +88,7 @@ func (v *Odb) Hash(data []byte, otype ObjectType) (oid *Oid, err error) {
|
|||
runtime.LockOSThread()
|
||||
defer runtime.UnlockOSThread()
|
||||
|
||||
ret := C.git_odb_hash(oid.toC(), ptr, C.size_t(header.Len), C.git_otype(otype));
|
||||
ret := C.git_odb_hash(oid.toC(), ptr, C.size_t(header.Len), C.git_otype(otype))
|
||||
if ret < 0 {
|
||||
err = MakeGitError(ret)
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ func (object *OdbObject) Data() (data []byte) {
|
|||
|
||||
len := int(C.git_odb_object_size(object.ptr))
|
||||
|
||||
sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&blob)))
|
||||
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&blob))
|
||||
sliceHeader.Cap = len
|
||||
sliceHeader.Len = len
|
||||
sliceHeader.Data = uintptr(c_blob)
|
||||
|
@ -185,7 +185,7 @@ func (stream *OdbReadStream) Free() {
|
|||
|
||||
type OdbWriteStream struct {
|
||||
ptr *C.git_odb_stream
|
||||
Id Oid
|
||||
Id Oid
|
||||
}
|
||||
|
||||
// Write writes to the stream
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestOdbStream(t *testing.T) {
|
|||
|
||||
func TestOdbHash(t *testing.T) {
|
||||
|
||||
repo := createTestRepo(t)
|
||||
repo := createTestRepo(t)
|
||||
defer os.RemoveAll(repo.Workdir())
|
||||
_, _ = seedTestRepo(t, repo)
|
||||
|
||||
|
@ -48,7 +48,7 @@ parent 66e1c476199ebcd3e304659992233132c5a52c6c
|
|||
author John Doe <john@doe.com> 1390682018 +0000
|
||||
committer John Doe <john@doe.com> 1390682018 +0000
|
||||
|
||||
Initial commit.`;
|
||||
Initial commit.`
|
||||
|
||||
oid, error := odb.Hash([]byte(str), ObjectCommit)
|
||||
checkFatal(t, error)
|
||||
|
|
|
@ -110,7 +110,7 @@ func (pb *Packbuilder) Written() uint32 {
|
|||
}
|
||||
|
||||
type packbuilderCbData struct {
|
||||
ch chan<- []byte
|
||||
ch chan<- []byte
|
||||
stop <-chan bool
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ func packbuilderForEachCb(buf unsafe.Pointer, size C.size_t, payload unsafe.Poin
|
|||
|
||||
slice := C.GoBytes(buf, C.int(size))
|
||||
select {
|
||||
case <- stop:
|
||||
case <-stop:
|
||||
return -1
|
||||
case ch <- slice:
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ func completionCallback(completion_type C.git_remote_completion_type, data unsaf
|
|||
if callbacks.CompletionCallback == nil {
|
||||
return 0
|
||||
}
|
||||
return callbacks.CompletionCallback((RemoteCompletion)(completion_type))
|
||||
return callbacks.CompletionCallback(RemoteCompletion(completion_type))
|
||||
}
|
||||
|
||||
//export credentialsCallback
|
||||
|
@ -92,7 +92,7 @@ func credentialsCallback(_cred **C.git_cred, _url *C.char, _username_from_url *C
|
|||
}
|
||||
url := C.GoString(_url)
|
||||
username_from_url := C.GoString(_username_from_url)
|
||||
ret, cred := callbacks.CredentialsCallback(url, username_from_url, (CredType)(allowed_types))
|
||||
ret, cred := callbacks.CredentialsCallback(url, username_from_url, CredType(allowed_types))
|
||||
*_cred = cred.ptr
|
||||
return ret
|
||||
}
|
||||
|
|
|
@ -27,9 +27,9 @@ int _go_git_opts_get_size_t(int opt, size_t *val)
|
|||
*/
|
||||
import "C"
|
||||
import (
|
||||
"github.com/libgit2/git2go"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
"github.com/libgit2/git2go"
|
||||
)
|
||||
|
||||
func MakeGitError(err C.int) error {
|
||||
|
@ -71,7 +71,7 @@ func getSizet(opt C.int) (int, error) {
|
|||
defer runtime.UnlockOSThread()
|
||||
|
||||
var val C.size_t
|
||||
err := C._go_git_opts_get_size_t(opt, &val);
|
||||
err := C._go_git_opts_get_size_t(opt, &val)
|
||||
if err < 0 {
|
||||
return 0, MakeGitError(err)
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func setSizet(opt C.int, val int) error {
|
|||
defer runtime.UnlockOSThread()
|
||||
|
||||
cval := C.size_t(val)
|
||||
err := C._go_git_opts_set_size_t(opt, cval);
|
||||
err := C._go_git_opts_set_size_t(opt, cval)
|
||||
if err < 0 {
|
||||
return MakeGitError(err)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package settings
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"runtime"
|
||||
"github.com/libgit2/git2go"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type pathPair struct {
|
||||
|
@ -13,9 +13,9 @@ type pathPair struct {
|
|||
|
||||
func TestSearchPath(t *testing.T) {
|
||||
paths := []pathPair{
|
||||
pathPair{git.ConfigLevelSystem, "/tmp/system"},
|
||||
pathPair{git.ConfigLevelGlobal, "/tmp/global"},
|
||||
pathPair{git.ConfigLevelXDG, "/tmp/xdg"},
|
||||
{git.ConfigLevelSystem, "/tmp/system"},
|
||||
{git.ConfigLevelGlobal, "/tmp/global"},
|
||||
{git.ConfigLevelXDG, "/tmp/xdg"},
|
||||
}
|
||||
|
||||
for _, pair := range paths {
|
||||
|
|
Loading…
Reference in New Issue